123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- using System.Collections;
- using System.Linq;
- using System.Collections.Generic;
- using UnityEngine;
- using Sirenix.OdinInspector;
- using KairoEngine.Core;
- namespace KairoEngine.Core.GameActions
- {
- [System.Serializable, HideReferenceObjectPicker]
- public class CompareBoolGameActionCondition : GameActionCondition
- {
- public override string name
- {
- get
- {
- return $"x equals y";
- }
- }
- public override GameActionsController controller {
- get => _controller;
- set
- {
- _controller = value;
- typeName = "CompareBoolGameActionCondition";
- GetCompatibleVariablenames();
- }
- }
- public override string GetTypeName() => "CompareBoolGameActionCondition";
- public override string GetActionName() => "Compare Booleans";
- [IconFoldoutGroup("@name","Assets/Plugins/KairoEngine/Core/Editor/Icons/CompareBoolGameActionConditionIcon.png")]
- [ValueDropdown("possibleVariables", IsUniqueList = false)]
- public string variable;
- [IconFoldoutGroup("@name")]
- public bool result = true;
- [IconFoldoutGroup("@name")]
- public bool equals = true;
- private IEnumerable possibleVariables = new ValueDropdownList<string>();
- public override bool Evaluate()
- {
- return true;
- }
- private void GetCompatibleVariablenames()
- {
- possibleVariables = _controller.context.variables
- .Where(x => x.GetTypeName() == "GameActioncontextBool")
- .Select(x => new ValueDropdownItem(x.name, x.name));
- }
- public static CompareBoolGameActionCondition JSONToCompareBoolGameActionCondition(string data)
- {
- return JsonUtility.FromJson<CompareBoolGameActionCondition>(data);
- }
- private CompareBoolGameActionCondition Duplicate()
- {
- CompareBoolGameActionCondition condition = new CompareBoolGameActionCondition();
- condition.controller = controller;
- condition.result = result;
- condition.equals = equals;
- condition.variable = variable;
- return condition;
- }
- private bool GetVariable(string title)
- {
- for (int i = 0; i < controller.context.variables.Count; i++)
- {
- if(controller.context.variables[i].name == title)
- {
- return controller.context.variables[i].GetValue<bool>(false);
- }
- }
- return false;
- }
- private void LogMessage(string value, DebugLogGameActionlogType logType)
- {
- switch (logType)
- {
- case DebugLogGameActionlogType.Log:
- Debug.Log(value);
- break;
- case DebugLogGameActionlogType.Warning:
- Debug.LogWarning(value);
- break;
- case DebugLogGameActionlogType.Error:
- Debug.LogError(value);
- break;
- default:
- break;
- }
- }
- }
- }
|