Esempio n. 1
0
 public void NormalAttack(object a_obj)
 {
     if (Stamina >= 1)
     {
         GameGlobals.ExecuteAttack(new Attack(this, 60, 1, Ori));
         Stamina--;
     }
 }
Esempio n. 2
0
        public void SwapBack()
        {
            if (Swapping)
            {
                Vector2 tmpPos = Position;
                Position = _swappedEnemy.Position + new Vector2(0, _swappedEnemy.Dimension.Y / 2 * _swappedEnemy.BoundingBoxOffset.W - Dimension.Y / 2);
                _swappedEnemy.Position = tmpPos + new Vector2(0, Dimension.Y / 2 * BoundingBoxOffset.W - _swappedEnemy.Dimension.Y / 2);

                GameGlobals.PassEffect(new WindEffect(this, new Vector2(Dimension.Y * 1.5f, Dimension.Y * 1.5f)));
                GameGlobals.PassEffect(new WindEffect(_swappedEnemy, new Vector2(Dimension.Y * 1.5f, Dimension.Y * 1.5f)));

                SwapTimer.ResetToZero();
                _swappedEnemy = null;
            }
        }
Esempio n. 3
0
        public override void Update(Vector2 a_offset, SquareGrid a_grid)
        {
            //a_grid.GetSlotFromPixel(Position, Vector2.Zero).Filled = false;

            Vector2 originalPosition = Position;

            if (_state == State.DASHING)
            {
                if (Ori == GameGlobals.Orientation.LEFT)
                {
                    HSpeed = -20.0f;
                }
                else
                {
                    HSpeed = 20.0f;
                }
            }
            else
            {
                HandleInput(a_offset, a_grid);
            }


            if (_state == State.JUMP_ATTACKING)
            {
                Attack jumpAttack = new Attack(this, 0, 1, GameGlobals.Orientation.BOT);
                GameGlobals.ExecuteAttack(jumpAttack);
                if (jumpAttack.LandedHit)
                {
                    VSpeed = -JumpSpeed * 0.8f;
                }
            }

            StartAnimation();

            UpdateTimers();

            _wasOnGround = OnGround;

            base.Update(a_offset, a_grid);

            GameGlobals.CheckScroll(Position);

            //a_grid.GetSlotFromPixel(Position, Vector2.Zero).Filled = true;
        }
Esempio n. 4
0
        public void SwapPositionWithClosestEnemy()
        {
            Npc closestEnemy = (Npc)GameGlobals.GetClosestNpc(this);

            if (closestEnemy != null && Math.Abs(closestEnemy.Position.X - Position.X) < 1000)
            {
                Vector2 tmpPos = Position;

                Position = closestEnemy.Position + new Vector2(0, closestEnemy.Dimension.Y / 2 * closestEnemy.BoundingBoxOffset.W - Dimension.Y / 2);
                closestEnemy.Position = tmpPos + new Vector2(0, Dimension.Y / 2 * BoundingBoxOffset.W - closestEnemy.Dimension.Y / 2);

                GameGlobals.PassEffect(new WindEffect(this, new Vector2(Dimension.Y * 1.5f, Dimension.Y * 1.5f)));
                GameGlobals.PassEffect(new WindEffect(closestEnemy, new Vector2(Dimension.Y * 1.5f, Dimension.Y * 1.5f)));

                Stamina -= 3;
                SwapTimer.ResetToZero();
                _swappedEnemy = closestEnemy;
            }
        }
Esempio n. 5
0
 public void NormalAttack(object a_obj)
 {
     GameGlobals.ExecuteEnemyAttack(new Attack(this, 60, 1, Ori));
 }
Esempio n. 6
0
        public void HandleInput(Vector2 a_offset, SquareGrid a_grid)
        {
            bool pressedSpace = Globals.MyKeyboard.GetPress("Space");

            if (OnGround && HSpeed == 0 && _state != State.ATTACKING && _state != State.JUMP_ATTACKING && _state != State.DYING)
            {
                _state = State.STANDING;
            }

            if (_state != State.ATTACKING && _state != State.JUMP_ATTACKING && _state != State.DYING)
            {
                // Runing stuff
                if (Globals.MyKeyboard.GetPress("A") || Globals.MyKeyboard.GetPress("Left"))
                {
                    HSpeed -= MovSpeed;
                }
                if (Globals.MyKeyboard.GetPress("D") || Globals.MyKeyboard.GetPress("Right"))
                {
                    HSpeed += MovSpeed;
                }

                // Jumping stuff
                if (Globals.MyKeyboard.GetNewPress("Space"))
                {
                    _jumpTimer = TimeSpan.FromMilliseconds(0);
                }
                if (!pressedSpace && _wasOnGround && !OnGround)
                {
                    _extraGroundTimer = TimeSpan.FromMilliseconds(0);
                }

                _jumpTimer        += Globals.GlobalGameTime.ElapsedGameTime;
                _extraGroundTimer += Globals.GlobalGameTime.ElapsedGameTime;

                if (_jumpTimer.TotalMilliseconds < 150 && (_extraGroundTimer.TotalMilliseconds < 75 || OnGround))
                {
                    VSpeed     = -JumpSpeed;
                    _jumpTimer = TimeSpan.FromMilliseconds(151);
                    _state     = State.JUMPING;
                }
                if (!pressedSpace && VSpeed < 0 && !OnGround)
                {
                    VSpeed *= 0.8f;
                }

                if (Globals.MyMouse.LeftClick())
                {
                    if (OnGround && Stamina >= 1)
                    {
                        _state = State.ATTACKING;
                    }
                }

                if (!OnGround && Stamina >= 1 && (Globals.MyKeyboard.GetPress("S") || Globals.MyKeyboard.GetPress("Down")))
                {
                    if (VSpeed < 0)
                    {
                        VSpeed = -0.1f;
                    }
                    Stamina--;
                    _state = State.JUMP_ATTACKING;
                }

                if (Stamina >= 3 && !Swapping && (Globals.MyKeyboard.GetPress("R")))
                {
                    SwapPositionWithClosestEnemy();
                }
            }
            else if (_state == State.JUMP_ATTACKING)
            {
                if (Globals.MyKeyboard.GetPress("A") || Globals.MyKeyboard.GetPress("Left"))
                {
                    HSpeed -= MovSpeed;
                }
                if (Globals.MyKeyboard.GetPress("D") || Globals.MyKeyboard.GetPress("Right"))
                {
                    HSpeed += MovSpeed;
                }
                if (Globals.MyMouse.LeftClick())
                {
                    _state = State.JUMPING;
                }
            }

            if (Globals.MyMouse.RightClick())
            {
                Vector2 tmpLocation = a_grid.GetLocationFromPixel(Globals.NewVector(Globals.MyMouse.NewMousePos) - a_offset, Vector2.Zero);

                GridLocation location = a_grid.GetSlotFromLocation(tmpLocation);

                if (location != null && !location.Filled && !location.Impassible)
                {
                    //location.SetToFilled(true);
                    FirstEnemy tmpEnemy = new FirstEnemy(Vector2.Zero, new Vector2(1, 1));

                    tmpEnemy.Position = location.Position + tmpEnemy.Dimension / 2;

                    GameGlobals.PassNpc(tmpEnemy);
                }
            }

            if (Globals.MyKeyboard.GetPress("LeftShift") && _state != State.DASHING && Stamina >= 3)
            {
                _state          = State.DASHING;
                IgnoringPhysics = true;
                VSpeed          = 0;
                Stamina        -= 3;
            }

            if (_state == State.STANDING && HSpeed != 0)
            {
                _state = State.RUNNING;
            }
        }