Example #1
0
 protected virtual void OnValueChangeEvent(double oldValue_, double newValue_)
 {
     if (ValueChangeEvent != null)
     {
         ValueChangeEvent.Invoke(oldValue_, newValue_);
     }
 }
Example #2
0
 void Start()
 {
     if (onValueChanged == null)
     {
         onValueChanged = new ValueChangeEvent();
     }
 }
        public Value(string Name, ValueChangeEvent Event)
        {
            this.Parent = Level.ReferenceObject;
            this.Name = Name;
            this.ChangeEvent = Event;

            Parent.AddValue(this);
        }
 private void Update()
 {
     //触发事件
     if (movementVector != Vector2.zero)
     {
         ValueChangeEvent?.Invoke(movementVector);
     }
 }
    public static void FocusOn(ValueChangeEventID vceID)
    {
        ValueChangeEvent vce = vceID.ValueChangeEvent;

        if (vce != null)
        {
            Selection.activeGameObject = vceID.Component.gameObject;
            vce.inspectorHighlight     = true;
        }
    }
    private void OnSpawnUnit()
    {
        if (units == null || units.Length != maxUnits)
        {
            ResizeUnitArray();
        }

        if (magazineCount <= 0)
        {
            return;
        }

        Transform spawnPoint;
        int       spawnPointCount = spawnPoints != null ? spawnPoints.Length : 0;

        spawnPoint = spawnPointCount > 0 ? spawnPoints[UnityEngine.Random.Range(0, spawnPointCount)] : transform;

        for (int i = 0; i < maxUnits; i++)
        {
            Body spawnedUnit = null;

            if (units[i] == null)
            {
                spawnedUnit = Instantiate(unitPrefab, spawnPoint.position, spawnPoint.rotation, transform);
                ValueChangeEvent.InitializeVCEs(spawnedUnit.gameObject);
                spawnedUnit.destroyBody.AddTriggerListener(OnUnitDeath);
                units[i] = spawnedUnit;
            }
            else if (units[i].IsAlive == false)
            {
                spawnedUnit = units[i];
                spawnedUnit.transform.position = spawnPoint.position;
                spawnedUnit.transform.rotation = spawnPoint.rotation;
                spawnedUnit.Respawn();
            }

            if (spawnedUnit != null)
            {
                CurrentSpawnedUnitCount += 1;
                if (magazineSize >= 0)
                {
                    magazineCount.Value = magazineCount - 1;
                }

                if (spawnedUnit is PhysicalBody)
                {
                    PhysicalBody physicalUnit = spawnedUnit as PhysicalBody;
                    physicalUnit.AttachedRigidBody.velocity        = transform.up * spawnVelocity;
                    physicalUnit.AttachedRigidBody.angularVelocity = 0f;
                }

                break;
            }
        }
    }
    public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
    {
        ValueChangeEvent target = ValueChangeEventID.FindValueChangeEvent(property.serializedObject.targetObject as Component, property.name);

        float height = EditorGUIUtility.singleLineHeight;

        if (target != null && mastersEditor != null)
        {
            height += mastersEditor.GetHeight() + EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
        }
        return(height);
    }
Example #8
0
 public IntValue(string Name, ValueChangeEvent Event)
     : base(Name)
 {
     this.ChangeEvent = Event;
     this.Value       = 0;
 }
Example #9
0
 public FloatValue(string Name, float Value, ValueChangeEvent Event)
     : base(Name)
 {
     this.Value       = Value;
     this.ChangeEvent = Event;
 }
Example #10
0
        public override void HSEvent(Enums.HSEvent eventType, object[] parameters)
        {
            bool canContinue = true;  // this.SettingsManager.Settings.IsEventTypeEnabled((int)eventType);

            if (!canContinue)
            {
                return;
            }

            BaseDocument document = null;

            try
            {
                switch (eventType)
                {
                case Enums.HSEvent.CONFIG_CHANGE:
                {
                    document = new ConfigChangeEvent(parameters);
                }
                break;

                case Enums.HSEvent.LOG:
                    document = new LogEvent(parameters);
                    break;

                case Enums.HSEvent.STRING_CHANGE:
                    document = new StringChangeEvent(parameters);
                    break;

                case Enums.HSEvent.VALUE_CHANGE:
                {
                    document = new ValueChangeEvent(parameters);
                }
                break;

                case Enums.HSEvent.GENERIC:
                {
                    document = new GenericEvent(parameters);
                }
                break;

                case Enums.HSEvent.SETUP_CHANGE:
                {
                    document = new SetupChangeEvent();
                }
                break;

                default:
                    LogInfo(string.Format("No handler yet for HSEvent type {0}", eventType.ToString()));
                    Console.WriteLine(" - HSEvent {0}: {1}", eventType.ToString(), String.Join(" | ", parameters));
                    break;
                }

                if (document != null)
                {
                    this.esManager.WriteDocument(document);
                }
            }
            catch (Exception e)
            {
                LogError(string.Format("Error while handling HS Event: {0}", e.Message));
            }
        }
Example #11
0
 public Texture2DValue(string Name, ValueChangeEvent Event)
     : base(Name, Event)
 {
     this.Value = null;
     this.Path  = "";
 }
Example #12
0
 public BoolValue(string Name, ValueChangeEvent Event)
     : base(Name, Event)
 {
     this.Value = false;
 }
Example #13
0
 public Vector2Value(string Name, Vector2 Value, ValueChangeEvent e)
     : base(Name, e)
 {
     this.Value = Value;
 }
Example #14
0
 public void updateValue(ValueChangeEvent _changing)
 {
     composite.getStrings().Add(_changing.getNewValue() + " " + _changing.getOldValue());
     changing = _changing;
 }
Example #15
0
 public Vector3Value(string Name, Vector3 Value, EditType editType, ValueChangeEvent Event)
     : base(Name, Event)
 {
     this.editType = editType;
     this.Value    = Value;
 }
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        ValueChangeEvent target = ValueChangeEventID.FindValueChangeEvent(property.serializedObject.targetObject as Component, property.name);

        if (target == null)
        {
            EditorGUI.LabelField(position, "(" + property.type + ")");
            return;
        }

        if (changeCheck == true)
        {
            changeCheck = false;
            target.Trigger();
            EditorUtility.SetDirty(property.serializedObject.targetObject as Component);
        }

        if (target.inspectorHighlight)
        {
            highlightProperty         = true;
            highlightStartTime        = Time.realtimeSinceStartup;
            target.inspectorHighlight = false;
        }

        if (highlightProperty == true)
        {
            HighlightFade(position, property);
        }

        Rect controlRect = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label);

        EditorGUI.BeginProperty(position, label, property);

        int indent = EditorGUI.indentLevel;

        EditorGUI.indentLevel = 0;

        SerializedProperty valueProperty     = property.FindPropertyRelative("value");
        SerializedProperty enumNamesProperty = property.FindPropertyRelative("enumNames");

        if (valueProperty != null)
        {
            ValueGUI(controlRect, valueProperty, enumNamesProperty);
        }
        else
        {
            TriggerGUI(controlRect);
        }

        Rect arrowRect = position;

        arrowRect.height = EditorGUIUtility.singleLineHeight;
        arrowRect.width  = position.width - controlRect.width;
        if (target.MasterCount == 0)
        {
            target.inspectorUnfold = EditorGUI.Foldout(arrowRect, target.inspectorUnfold, GUIContent.none, true, GUIStyle.none);
        }
        else
        {
            target.inspectorUnfold = EditorGUI.Foldout(arrowRect, target.inspectorUnfold, GUIContent.none, true);
        }

        if (target.inspectorUnfold)
        {
            if (mastersEditor == null || mastersEditor.target != target)
            {
                mastersEditor = new ValueChangeEventMastersEditor(target);
            }
            position.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
            mastersEditor.OnGUI(position, ref changeCheck);
        }
        else if (mastersEditor != null)
        {
            mastersEditor = null;
        }

        EditorGUI.indentLevel = indent;
        EditorGUI.EndProperty();
    }
Example #17
0
 public void bind(ValueChangeEvent valueChangeEvent)
 {
     this.events.Add(valueChangeEvent);
 }
Example #18
0
 public void changeText(ValueChangeEvent _event)
 {
     newOld = _event.getNewValue() + " " + _event.getOldValue();
 }
Example #19
0
 public BindProperty(ValueChangeEvent _callback)
 {
     ValueChanged += _callback;
 }
Example #20
0
 public Vector3Value(string Name, Vector3 Value, ValueChangeEvent Event)
     : base(Name, Event)
 {
     this.Value = Value;
 }