Exemple #1
0
        private void Start()
        {
            _animation = GetComponent <Animation>();
            if (!_animation)
            {
                Debug.Log(
                    "The character you would like to control doesn't have animations. Moving her might look weird.");
            }
            else
            {
                _animation[Animations.Run.name].speed         = ControllerParams.RunAnimationSpeed;
                _animation[Animations.TurnToRight.name].speed = ControllerParams.TurningAnimationSpeed;
                _animation[Animations.TurnToLeft.name].speed  = ControllerParams.TurningAnimationSpeed;
                for (int i = 0; i < Animations.JumpDown.Length; i++)
                {
                    _animation[Animations.JumpDown[i].name].speed = ControllerParams.JumpDownAnimationSpeed;
                }
                for (int i = 0; i < Animations.JumpDown.Length; i++)
                {
                    _animation[Animations.JumpUp[i].name].speed = ControllerParams.JumpUpAnimationSpeed;
                }
            }
            track = TrackAbstract.GetInstance();
            if (!track)
            {
                track = null;
                Debug.Log("No Track found. Character can`t move without Track");
            }
            _transform          = transform;
            characterController = GetComponent <CharacterController>();
            instance            = this;

            ControllerParams.JumpVerticalSpeed = Mathf.Sqrt(2 * ControllerParams.JumpHeight * ControllerParams.Gravity);
            ControllerColliderDeadHeight       = characterController.center.y + characterController.height * 0.5f;

            runingState         = new RuningState(this);
            turningState        = new TurningState(this);
            jumpingState        = new JumpingState(this);
            disallowedTurnState = new DisallowedTurningState(this);
            stramedState        = new StameredState(this);
            deadState           = new DeadState(this);
            shieldAttackState   = new ShieldAttackState(this, ControllerParams.ShieldAttackTime);
            swordAttackState    = new SwordAttackState(this, ControllerParams.SwordAttackTime);
            ropeRollingState    = new RopeRollingState(this);
            colliderRelSaved    = characterController.center;
            PrepareToReplay();

            if (footFlares)
            {
                footFlares.maxBrightness = MaxFlireBrightness;
                footFlares.TurnOff();
            }

            life = new Life();
        }
Exemple #2
0
        public override void Jump()
        {
            JumpingState newJumping = new JumpingState(Controller.GetInstance());

            Controller.SavedStates.PutState(newJumping);
        }