//--------------------------------------------------------------------------------------------/
        // Methods
        //--------------------------------------------------------------------------------------------/
        public IEnumerator MakeInterpolateRoutine()
        {
            IEnumerator interpolator = null;

            switch (memberType)
            {
            case StratusActionProperty.Types.Integer:
            {
                int  currentValue = member.Get <int>();
                bool shouldToggle = (toggle && currentValue == intValue);
                int  nextValue    = shouldToggle ? (int)previousValue : intValue;
                //interpolator = Routines.Lerp(currentValue, nextValue, duration, (float val) => { property.Set(Mathf.CeilToInt(val)); }, Routines.Lerp);
                interpolator  = StratusRoutines.Interpolate(currentValue, nextValue, duration, (float val) => { member.Set(Mathf.CeilToInt(val)); }, ease);
                previousValue = currentValue;
            }
            break;

            case StratusActionProperty.Types.Float:
            {
                float currentValue = member.Get <float>();
                bool  shouldToggle = (toggle && currentValue == floatValue);
                StratusDebug.Log("Previous float " + previousValue + ", Current Float = " + currentValue + ", Float Value = " + floatValue + ", shouldToggle = " + shouldToggle);
                float nextValue = shouldToggle ? (float)previousValue : floatValue;
                //interpolator = Routines.Lerp(currentValue, nextValue, duration, (float val) => { property.Set(val); }, Routines.Lerp);
                interpolator  = StratusRoutines.Interpolate(currentValue, nextValue, duration, (float val) => { member.Set(val); }, ease);
                previousValue = currentValue;
            }
            break;

            case StratusActionProperty.Types.Boolean:
            {
                bool currentValue = member.Get <bool>();
                bool shouldToggle = (toggle && currentValue == boolValue);
                bool nextValue    = shouldToggle ? (bool)previousValue : boolValue;
                interpolator  = StratusRoutines.Call(() => { member.Set(nextValue); }, duration);
                previousValue = currentValue;
            }
            break;

            case StratusActionProperty.Types.Vector2:
            {
                Vector2 currentValue = member.Get <Vector2>();
                bool    shouldToggle = (toggle && currentValue == vector2Value);
                Vector2 nextValue    = shouldToggle ? (Vector2)previousValue : vector2Value;
                //interpolator = Routines.Lerp(currentValue, nextValue, duration, (Vector2 val) => { property.Set(val); }, Vector2.Lerp);
                interpolator  = StratusRoutines.Interpolate(currentValue, nextValue, duration, (Vector2 val) => { member.Set(val); }, ease);
                previousValue = currentValue;
            }
            break;

            case StratusActionProperty.Types.Vector3:
            {
                Vector3 currentValue = member.Get <Vector3>();
                bool    shouldToggle = (toggle && currentValue == vector3Value);
                Vector3 nextValue    = shouldToggle ? (Vector3)previousValue : vector3Value;
                //interpolator = Routines.Lerp(currentValue, nextValue, duration, (Vector3 val) => { property.Set(val); }, Vector3.Lerp);
                interpolator  = StratusRoutines.Interpolate(currentValue, nextValue, duration, (Vector3 val) => { member.Set(val); }, ease);
                previousValue = currentValue;
            }
            break;

            case StratusActionProperty.Types.Vector4:
            {
                Vector4 currentValue = member.Get <Vector4>();
                bool    shouldToggle = (toggle && currentValue == vector4Value);
                Vector4 nextValue    = shouldToggle ? (Vector4)previousValue : vector4Value;
                //interpolator = Routines.Lerp(currentValue, nextValue, duration, (Vector4 val) => { property.Set(val); }, Vector4.Lerp);
                interpolator  = StratusRoutines.Interpolate(currentValue, nextValue, duration, (Vector4 val) => { member.Set(val); }, ease);
                previousValue = currentValue;
            }
            break;

            case StratusActionProperty.Types.Color:
            {
                Color currentValue = member.Get <Color>();
                bool  shouldToggle = (toggle && currentValue == colorValue);
                Color nextValue    = shouldToggle ? (Color)previousValue : colorValue;
                //interpolator = Routines.Lerp(currentValue, nextValue, duration, (Color val) => { property.Set(val); }, Color.Lerp);
                interpolator  = StratusRoutines.Interpolate(currentValue, nextValue, duration, (Color val) => { member.Set(val); }, ease);
                previousValue = currentValue;
            }
            break;

            default:
                break;
            }
            return(interpolator);
        }
Beispiel #2
0
 /// <summary>
 /// Runs a coroutine on this behaviour that will invoke the given action after the set amount of time
 /// </summary>
 /// <param name="enumerator"></param>
 /// <returns></returns>
 public Coroutine Invoke(Action action, float delay)
 {
     return(this.StartCoroutine(StratusRoutines.Call(action, delay)));
 }