Example #1
0
        public override void Attack(AttackType attackType)
        {
            if (!wasInAirWhenAttacked)
            {
                wasInAirWhenAttacked = true;
                base.Attack(attackType);
            }
            else
            {
                switch (attackType)
                {
                case AttackType.Sword:
                {
                    SwordAttackState sword = new SwordAttackState(controller, controller.ControllerParams.SwordAttackTime);
                    Controller.SavedStates.PutState(sword);
                    break;
                }

                case AttackType.Shield:
                {
                    ShieldAttackState shield = new ShieldAttackState(controller, controller.ControllerParams.ShieldAttackTime);
                    Controller.SavedStates.PutState(shield);
                    break;
                }
                }
            }
        }
Example #2
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();
        }
Example #3
0
        public override void Attack(AttackType type)
        {
            switch (type)
            {
            case AttackType.Sword:
            {
                SwordAttackState sword = new SwordAttackState(controller, controller.ControllerParams.SwordAttackTime);
                Controller.SavedStates.PutState(sword);
                break;
            }

            case AttackType.Shield:
            {
                ShieldAttackState shield = new ShieldAttackState(controller, controller.ControllerParams.ShieldAttackTime);
                Controller.SavedStates.PutState(shield);
                break;
            }
            }
        }