Example #1
0
        public void ForceValue(float Ratio)
        {
            object value = PropertyChange.GetValue(changeValue_component, changeValue_property, changeValue_subproperty);

            if (value != null)
            {
                value = ActionValue.Lerp(value.GetType(), changeValue_constant_finalRange_from, changeValue_constant_finalRange_to, Ratio);
                UpdateValue(value);
            }
        }
Example #2
0
 public void Update()
 {
     if (waitTime > 0 && _timer_wait > 0)
     {
         _timer_wait -= Time.deltaTime;
         if (_timer_wait < 0)
         {
             Activate();
         }
     }
     if (_timer_valueTo > 0 && !parent.isTypeConstant && duration > 0)
     {
         UpdateValue(ActionValue.Lerp(_previousValue, _nextValue, 1 - Mathf.Clamp01(_timer_valueTo / duration)));
         _timer_valueTo -= Time.deltaTime;
         if (_timer_valueTo < 0)
         {
             // tween ended
             UnRegisterTween(changeValue_component, this);
             UpdateValue(_nextValue);
             OnValueChangeEnd(_nextValue);
         }
     }
 }
Example #3
0
        void Activate()
        {
            _everActivated = true;
            //Debug.Log ("action enter! " + type, parent);
            if (type == Type.ChangeValue)
            {
                //TriggerManager.ChangeValueOverTime(target, time, value);
                //TODO: get type of a subproperty to properly put the right field
                object value = PropertyChange.GetValue(changeValue_component, changeValue_property, changeValue_subproperty);
                if (value != null)
                {
                    if (!parent.isTypeConstant)
                    {
                        _previousValue = value;
                        value          = changeValue_value.Get(value.GetType());

                        ChangeValueTo(value, _previousValue);
                    }
                    else
                    {
                        float d = Vector3.Distance(constantValueFromPosition, constantValueToPosition);
                        d -= changeValue_constant_nearDistance;
                        d /= changeValue_constant_farDistance - changeValue_constant_nearDistance;
                        d  = 1 - Mathf.Clamp01(d);
                        d  = changeValue_constant_curve.Evaluate(d);

                        value = ActionValue.Lerp(value.GetType(), changeValue_constant_finalRange_from, changeValue_constant_finalRange_to, d);

                        UpdateValue(value);
                    }
                }
            }
            else if (type == Type.MovePlayer)
            {
                if (movePlayer_movementType == PlayerMovementType.ForcePosition)
                {
                    changeValue_component   = Player.instance.transform;
                    changeValue_property    = "position";
                    changeValue_subproperty = "";
                    ChangeValueTo(changeValue_value.GetVector3(), Player.instance.transform.position);
                }
                else if (movePlayer_movementType == PlayerMovementType.Poke)
                {
                    Player.instance.controller.Move(changeValue_value.GetVector3());
                }
            }
            else if (type == Type.MoveObject)
            {
                if (movePlayer_movementType == PlayerMovementType.ForcePosition)
                {
                    changeValue_component   = target.transform;
                    changeValue_property    = "position";
                    changeValue_subproperty = "";
                    ChangeValueTo(changeValue_value.GetVector3(), target.transform.position);
                }
                else if (movePlayer_movementType == PlayerMovementType.Poke)
                {
                    changeValue_component   = target.transform;
                    changeValue_property    = "position";
                    changeValue_subproperty = "";
                    ChangeValueTo(target.transform.position + changeValue_value.GetVector3(), target.transform.position);
                }
            }
            else if (type == Type.ActivateObject)
            {
                bool state = activate_flipValue ? !target.activeSelf : changeValue_value.GetBool();
                target.SetActive(state);
            }
            else if (type == Type.PlayAnimation)
            {
                if (playAnimation_loop)
                {
                    playAnimation_animation.clip.wrapMode = WrapMode.Loop;
                }
                if (playAnimation_queue)
                {
                    playAnimation_animation.PlayQueued(playAnimation_animation_clip, QueueMode.CompleteOthers);
                }
                else
                {
                    playAnimation_animation.Play(playAnimation_animation_clip);
                }
            }
            else if (type == Type.ChangeScene)
            {
                // TODO: transition through a manager
                TransitionManager.instance.TransitionTo(System.IO.Path.GetFileNameWithoutExtension(changeScene_scenePath), changeScene_duration, changeScene_transitionTexture, changeScene_transitionWaveTexture, changeScene_transitionSound);
            }
            else if (type == Type.PlaySound)
            {
                foreach (var sound in GetSounds())
                {
                    if (sound != null && sound.gameObject.activeSelf)
                    {
                        sound.Play();
                    }
                }
            }
            else if (type == Type.FadeSound)
            {
                if (sound_changeType == SoundChangeType.Single)
                {
                    changeValue_component   = sound_audioSource;
                    changeValue_property    = "volume";
                    changeValue_subproperty = "";
                    ChangeValueTo(changeValue_value.GetFloat(), sound_audioSource.volume);
                }
                else if (sound_changeType == SoundChangeType.All)
                {
                    Scene.current.FadeAllSounds(changeValue_value.GetFloat(), duration);
                }
            }
            else if (type == Type.StopSound)
            {
                /*
                 * changeValue_component = sound_audioSource;
                 * changeValue_property = "volume";
                 * changeValue_subproperty = "";
                 * changeValue_value.Set(0f);
                 * ChangeValueTo(changeValue_value.GetFloat(), sound_audioSource.volume);
                 */
                foreach (var sound in GetSounds())
                {
                    if (sound != null)
                    {
                        sound.Stop();
                    }
                }
            }
            else if (type == Type.ChangeCameraMode)
            {
                CameraController.instance.MoveCamera(changeCameraMode_mode, changeCameraMode_time, changeCameraMode_target);
                if (changeCameraMode_mode == CameraController.CameraMode.TopDownWithMouseControls)
                {
                    CameraController.instance._topdown_follow = changeCameraMode_topdownFollow;
                }
            }
            else if (type == Type.ChangeAvatar)
            {
                Player.instance.SwitchAvatar(changeAvatar_prefab);
            }
            else if (type == Type.ChangePlayerSounds)
            {
                Player.instance.SwitchSounds(playerSound_footsteps, playerSound_jump, playerSound_land, playerSound_air);
            }
            else if (type == Type.ShowMusicalDialog)
            {
                if (musicalDialog_dialog)
                {
                    musicalDialog_dialog.Play();
                }
            }
            else if (type == Type.ChangeMouseCursor)
            {
                if (texture != null)
                {
                    Cursor.SetCursor(texture, new Vector2(texture.width * changeCursor_hotspot.x, texture.height * changeCursor_hotspot.y), CursorMode.Auto);
                }
            }
            else if (type == Type.SwapSkybox)
            {
                if (changeMaterial_material != null)
                {
                    RenderSettings.skybox = changeMaterial_material;
                }
            }
        }