コード例 #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()
        {
            var player = Objects.ObjFind <Player>(0);

            if (player != null)
            {
                if (GameMath.Distance(Position, player.Position) < 100 && !_active)
                {
                    _active = true;
                    player.ControlsEnabled = false;
                    player.Speaking        = false;
                    player.LinePtr        -= 1;
                    if (player.LinePtr < -1)
                    {
                        player.LinePtr = -1;
                    }
                    Objects.Destroy(player.Bubble);

                    var npcs = Objects.GetList <NPC>();

                    double shortestDist = 1000000000;

                    foreach (NPC npc in npcs)
                    {
                        var d = GameMath.Distance(Position, npc.Position);
                        if (d < shortestDist)
                        {
                            _other       = npc;
                            shortestDist = d;
                        }
                    }
                }
            }

            if (_active && (_bubble == null || _bubble.Destroyed))
            {
                LinePtr += 1;
                if (LinePtr >= Lines.Length / 2)
                {
                    Objects.Destroy(this);
                    player.ControlsEnabled = true;
                    player.Speaking        = true;

                    if (Lines == _villainDialogue)
                    {
                        GameCntrl.ExitGame();
                    }
                }
                else
                {
                    if (Lines[LinePtr * 2] == "me")
                    {
                        _bubble = new SpeechBubble(player, Lines[LinePtr * 2 + 1]);
                    }
                    else
                    {
                        _bubble = new SpeechBubble(_other, Lines[LinePtr * 2 + 1]);
                    }
                }
            }
        }