变量模块;Element启用控制
This commit is contained in:
@@ -0,0 +1,124 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Ichni.Editor;
|
||||
using Ichni.RhythmGame.Beatmap;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Ichni.RhythmGame
|
||||
{
|
||||
public class EnableControlEffect : EffectBase
|
||||
{
|
||||
public GameElement connectedGameElement;
|
||||
public string connectedVariableName;
|
||||
public int enableValue;
|
||||
|
||||
public bool useExpression;
|
||||
public string expression;
|
||||
|
||||
public EnableControlEffect(GameElement connectedGameElement, string connectedVariableName,
|
||||
int enableValue, bool useExpression, string expression)
|
||||
{
|
||||
this.effectTime = 0;
|
||||
this.connectedGameElement = connectedGameElement;
|
||||
this.connectedVariableName = connectedVariableName;
|
||||
this.enableValue = enableValue;
|
||||
this.useExpression = useExpression;
|
||||
this.expression = expression;
|
||||
}
|
||||
|
||||
public override void Recover()
|
||||
{
|
||||
if (connectedGameElement == null) return;
|
||||
|
||||
connectedGameElement.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
public override void Adjust()
|
||||
{
|
||||
if (connectedGameElement == null) return;
|
||||
|
||||
if (!useExpression)
|
||||
{
|
||||
int value = EditorManager.instance.variablesContainer.GetVariable(connectedVariableName);
|
||||
connectedGameElement.gameObject.SetActive(value == enableValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public override EffectBase_BM ConvertToBM()
|
||||
{
|
||||
return new EnableControlEffect_BM(connectedGameElement.elementGuid,
|
||||
connectedVariableName, enableValue, useExpression, expression);
|
||||
}
|
||||
|
||||
public override void SetUpInspector()
|
||||
{
|
||||
IHaveInspection inspector = EditorManager.instance.uiManager.inspector;
|
||||
Inspector inspectorMain = EditorManager.instance.uiManager.inspector;
|
||||
|
||||
var container = inspector.GenerateContainer("Enable Control");
|
||||
var connectedGameElementInputField = inspector.GenerateInputField(container, "Game Element Name");
|
||||
var connectGameElementButton = inspector.GenerateButton(this, container, "Connect Game Element", () =>
|
||||
{
|
||||
connectedGameElement = EditorManager.instance.beatmapContainer.gameElementList
|
||||
.First(e => e.elementName == connectedGameElementInputField.GetValue<string>());
|
||||
|
||||
if (connectedGameElement == null)
|
||||
{
|
||||
LogWindow.Log("Game Element not found.", Color.red);
|
||||
}
|
||||
|
||||
inspectorMain.SetInspector(EditorManager.instance.operationManager.currentSelectedElement);
|
||||
});
|
||||
|
||||
string ShowConnection() => connectedGameElement == null ? "No Game Element Connected" : "Connected With: " + connectedGameElement.elementName;
|
||||
var connectHintText = inspector.GenerateHintText(this, container, ShowConnection);
|
||||
|
||||
var connectedVariableNameInputField = inspector.GenerateInputField(this, container, "Connected Variable Name", nameof(connectedVariableName));
|
||||
var enableValueInputField = inspector.GenerateInputField(this, container, "Enable Value", nameof(enableValue));
|
||||
|
||||
var useExpressionToggle = inspector.GenerateToggle(this, container, "Use Expression", nameof(useExpression));
|
||||
useExpressionToggle.toggle.interactable = false;
|
||||
var expressionInputField = inspector.GenerateInputField(this, container, "Expression", nameof(expression));
|
||||
expressionInputField.inputField.interactable = false;
|
||||
}
|
||||
}
|
||||
|
||||
namespace Beatmap
|
||||
{
|
||||
public class EnableControlEffect_BM : EffectBase_BM
|
||||
{
|
||||
public Guid connectedGameElementGuid;
|
||||
public string connectedVariableName;
|
||||
public int enableValue;
|
||||
public bool useExpression;
|
||||
public string expression;
|
||||
|
||||
public EnableControlEffect_BM()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public EnableControlEffect_BM(Guid connectedGameElementGuid, string connectedVariableName,
|
||||
int enableValue, bool useExpression, string expression)
|
||||
{
|
||||
this.connectedGameElementGuid = connectedGameElementGuid;
|
||||
this.connectedVariableName = connectedVariableName;
|
||||
this.enableValue = enableValue;
|
||||
this.useExpression = useExpression;
|
||||
this.expression = expression;
|
||||
}
|
||||
|
||||
public override EffectBase ConvertToGameType(GameElement attachedGameElement)
|
||||
{
|
||||
return new EnableControlEffect(GameElement_BM.GetElement(connectedGameElementGuid), connectedVariableName,
|
||||
enableValue, useExpression, expression);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1117b38637ccd4eae86b05caa2160ab5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,87 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Ichni.Editor;
|
||||
using Ichni.RhythmGame.Beatmap;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Ichni.RhythmGame
|
||||
{
|
||||
public class SetIntegerEffect : EffectBase
|
||||
{
|
||||
public string targetVariableName;
|
||||
|
||||
public int targetValue;
|
||||
|
||||
public bool isRandom;
|
||||
public int minValue;
|
||||
public int maxValue;
|
||||
|
||||
public SetIntegerEffect(string targetVariableName, int targetValue, bool isRandom, int minValue, int maxValue)
|
||||
{
|
||||
this.effectTime = 0;
|
||||
this.targetVariableName = targetVariableName;
|
||||
this.targetValue = targetValue;
|
||||
this.isRandom = isRandom;
|
||||
this.minValue = minValue;
|
||||
this.maxValue = maxValue;
|
||||
}
|
||||
|
||||
public override void Recover()
|
||||
{
|
||||
EditorManager.instance.variablesContainer.RevertVariable(targetVariableName);
|
||||
}
|
||||
|
||||
public override void Adjust()
|
||||
{
|
||||
EditorManager.instance.variablesContainer.SetVariable(targetVariableName, isRandom ? Random.Range(minValue, maxValue + 1) : targetValue);
|
||||
}
|
||||
|
||||
public override EffectBase_BM ConvertToBM()
|
||||
{
|
||||
return new SetIntegerEffect_BM(targetVariableName, targetValue, isRandom, minValue, maxValue);
|
||||
}
|
||||
|
||||
public override void SetUpInspector()
|
||||
{
|
||||
IHaveInspection inspector = EditorManager.instance.uiManager.inspector;
|
||||
var container = inspector.GenerateContainer("Set Integer");
|
||||
var targetVariableNameInputField = inspector.GenerateInputField(this, container, "Target Variable Name", nameof(targetVariableName));
|
||||
var targetValueInputField = inspector.GenerateInputField(this, container, "Target Value", nameof(targetValue));
|
||||
var isRandomToggle = inspector.GenerateToggle(this, container, "Is Random", nameof(isRandom));
|
||||
var minValueInputField = inspector.GenerateInputField(this, container, "Min Value", nameof(minValue));
|
||||
var maxValueInputField = inspector.GenerateInputField(this, container, "Max Value", nameof(maxValue));
|
||||
}
|
||||
}
|
||||
|
||||
namespace Beatmap
|
||||
{
|
||||
public class SetIntegerEffect_BM : EffectBase_BM
|
||||
{
|
||||
public string targetVariableName;
|
||||
public int targetValue;
|
||||
public bool isRandom;
|
||||
public int minValue;
|
||||
public int maxValue;
|
||||
|
||||
public SetIntegerEffect_BM()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public SetIntegerEffect_BM(string targetVariableName, int targetValue, bool isRandom, int minValue, int maxValue)
|
||||
{
|
||||
this.effectTime = 0;
|
||||
this.targetVariableName = targetVariableName;
|
||||
this.targetValue = targetValue;
|
||||
this.isRandom = isRandom;
|
||||
this.minValue = minValue;
|
||||
this.maxValue = maxValue;
|
||||
}
|
||||
|
||||
public override EffectBase ConvertToGameType(GameElement attachedGameElement)
|
||||
{
|
||||
return new SetIntegerEffect(targetVariableName, targetValue, isRandom, minValue, maxValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3abb71bdf6fc94cd982379ef2f5161fb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -30,6 +30,7 @@ namespace Ichni.RhythmGame
|
||||
|
||||
private void Update()
|
||||
{
|
||||
effectSubmodule.effectCollection["Prior"].ForEach(effect => effect.UpdateEffect(time));
|
||||
effectSubmodule.effectCollection["Default"].ForEach(effect => effect.UpdateEffect(time));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user