コード例 #1
0
        /// <summary>
        /// Updates a given parameter in the character animator
        /// </summary>
        /// <param name="characterAnimator"></param>
        public void Update(StratusCharacterAnimator characterAnimator)
        {
            switch (parameterType)
            {
            case AnimatorControllerParameterType.Float:
                characterAnimator.SetFloat(parameterName, member.Get <float>());
                break;

            case AnimatorControllerParameterType.Int:
                characterAnimator.SetInteger(parameterName, member.Get <int>());
                break;

            case AnimatorControllerParameterType.Bool:
                characterAnimator.SetBoolean(parameterName, member.Get <bool>());
                break;
            }
        }
コード例 #2
0
        /// <summary>
        /// Records the current value of the given member
        /// </summary>
        /// <returns></returns>
        public bool Collect()
        {
            if (!member.isAssigned)
            {
                return(false);
            }

            latestValue = member.Get();
            return(true);
        }
コード例 #3
0
            public void Update()
            {
                if (!member.isAssigned)
                {
                    return;
                }

                latestValue = member.Get();
                if (hasValue)
                {
                    description = $"{prefixString} = {latestValue.ToString()}";
                }
                else
                {
                    description = $"{prefixString} = NULL";
                }
            }
コード例 #4
0
        //--------------------------------------------------------------------------------------------/
        // 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);
        }
コード例 #5
0
 //------------------------------------------------------------------------/
 // Methods
 //------------------------------------------------------------------------/
 public object Get()
 {
     return(member.Get());
 }