コード例 #1
0
        public override void Update()
        {
            _chargingJump = Input.CheckButton(_jumpButton) && ControlsEnabled;

            #region Movement controls.
            if (Input.CheckButton(_leftPawButton))
            {
                LeftPaw.StartStep();
            }
            if (Input.CheckButtonRelease(_leftPawButton) || !ControlsEnabled)
            {
                LeftPaw.StopStep();
            }
            if (Input.CheckButton(_rightPawButton))
            {
                RightPaw.StartStep();
            }
            if (Input.CheckButtonRelease(_rightPawButton) || !ControlsEnabled)
            {
                RightPaw.StopStep();
            }
            #endregion Movement controls.

            base.Update();



            if (_dead)
            {
                _deathAlarm.Update();

                if (_deathAlarm.Triggered)
                {
                    if (_deathStage == 0)
                    {
                        _deathScrEnabled = true;

                        LeftPaw.Position  += CheckpointPos - Position;
                        RightPaw.Position += CheckpointPos - Position;
                        Position           = CheckpointPos;
                        _cam.Position      = Position;

                        _deathAlarm.Set(0.25);
                    }
                    if (_deathStage == 1)
                    {
                        _deathScrEnabled = false;
                        ControlsEnabled  = true;
                        _dead            = false;
                    }

                    _deathStage += 1;
                }

                FaceSprite = SpritesDefault.FoxFaceSad;
            }
            else
            {
                FaceSprite = SpritesDefault.FoxFace;
            }



            foreach (Checkpoint checkpoint in Objects.GetList <Checkpoint>())
            {
                if (GameMath.Distance(Position, checkpoint.Position) < 32)
                {
                    CheckpointPos = Position;
                }
            }

            if ((Bubble == null || Bubble.Destroyed) && Speaking)
            {
                LinePtr += 1;
                if (LinePtr >= Lines.Length)
                {
                    Speaking = false;
                }
                else
                {
                    Bubble = new SpeechBubble(this, Lines[LinePtr]);
                }
            }

            if (ControlsEnabled && Input.CheckButtonPress(_previousLineButton))
            {
                // Don't ask.
                LinePtr -= 2;
                Speaking = true;
                if (LinePtr < -1)
                {
                    LinePtr = -1;
                }
                if (Bubble != null)
                {
                    Objects.Destroy(Bubble);
                }
            }
        }
コード例 #2
0
        public override void Update()
        {
            // Jump.
            if (_chargingJump)
            {
                LeftPaw.StopStep();
                RightPaw.StopStep();

                if (!_jumpChargeReady && !_jumpCharge.Active)
                {
                    _jumpCharge.Set(_jumpChargeTime);
                }

                if (_jumpCharge.Update())
                {
                    _jumpChargeReady = true;
                }
            }
            else
            {
                if (_jumpChargeReady)
                {
                    Zspd = 320;
                }
                _jumpChargeReady = false;
                _jumpCharge.Reset();
            }
            // Jump.


            PawTrail.Update();


            FacingDirection = GameMath.Direction(RightPaw.Position, LeftPaw.Position) + 90;
            if (FacingDirection >= 360)
            {
                FacingDirection -= 360;
            }

            Move((LeftPaw.Position + RightPaw.Position) / 2f);
            Depth = -(int)Position.Y;


            Zspd -= (float)GameCntrl.Time(Gravity);
            Z    += (float)GameCntrl.Time(Zspd);
            if (Z < 0)
            {
                Z    = 0;
                Zspd = 0;
            }

            if (Z > 0)
            {
                LeftPaw.CurrentState  = Paw.State.Jumping;
                RightPaw.CurrentState = Paw.State.Jumping;
            }
            else
            {
                if (LeftPaw.CurrentState == Paw.State.Jumping)
                {
                    LeftPaw.CurrentState = Paw.State.Resting;
                }
                if (RightPaw.CurrentState == Paw.State.Jumping)
                {
                    RightPaw.CurrentState = Paw.State.Resting;
                }
            }

            if (_jumpCharge.Active || _jumpChargeReady)
            {
                _jumpChargeZ = -(float)Math.Sqrt(1 - _jumpCharge.Counter / _jumpChargeTime) * _jumpChargeZMax;
            }
            else
            {
                _jumpChargeZ = _jumpChargeZ / 2f;
            }
        }