Exemplo n.º 1
0
 public override void Update()
 {
     if (InputHandler.playerUp())
     {
         selected = selected - 1 == -1 ? 2 : selected - 1;
     }
     if (InputHandler.playerDown())
     {
         selected = selected + 1 == 2 ? 0 : selected + 1;
     }
     if (InputHandler.playerSelect())
     {
         selectOption();
     }
 }
Exemplo n.º 2
0
        //Update function returns damage, this damage is then sent to an enemy if he is standing
        //where the player attacks
        public int Update(Tiles[,] around)
        {
            int deal = 0;


            //used to tween from where the character currently is to the expected grid
            //(means that they dont just jump around the map they smoothly transition)
            if (globalX != getGlobalX() || globalY != getGlobalY())
            {
                if (globalX < getGlobalX())
                {
                    globalX++;
                }
                if (globalX > getGlobalX())
                {
                    globalX--;
                }

                if (globalY < getGlobalY())
                {
                    globalY++;
                }
                if (globalY > getGlobalY())
                {
                    globalY--;
                }
            }
            else
            {
                if (moving)
                {
                    if (InputHandler.playerUp())
                    {
                        //if where the player is looking is a wall or a passage, they cant move fowards
                        if (direction == Direction.NORTH && around[1, 2] != Tiles.WALL && around[1, 2] != Tiles.FAKEPASSAGE)
                        {
                            y     += 1;
                            moving = false;
                        }

                        //if a fake passage, write to console (TODO: display in game)
                        if (around[1, 2] == Tiles.FAKEPASSAGE)
                        {
                            Console.WriteLine("CANT ENTER THIS PASSAGE");
                        }
                        direction = Direction.NORTH;
                        current   = up;
                    }
                    if (InputHandler.playerDown())
                    {
                        if (direction == Direction.SOUTH && around[1, 0] != Tiles.WALL && around[1, 0] != Tiles.FAKEPASSAGE)
                        {
                            y     -= 1;
                            moving = false;
                        }
                        else
                        {
                        }
                        if (around[1, 0] == Tiles.FAKEPASSAGE)
                        {
                            Console.WriteLine("CANT ENTER THIS PASSAGE");
                        }
                        direction = Direction.SOUTH;
                        current   = down;
                    }
                    if (InputHandler.playerLeft())
                    {
                        if (direction == Direction.WEST && around[0, 1] != Tiles.WALL && around[0, 1] != Tiles.FAKEPASSAGE)
                        {
                            x     -= 1;
                            moving = false;
                        }
                        if (around[0, 1] == Tiles.FAKEPASSAGE)
                        {
                            Console.WriteLine("CANT ENTER THIS PASSAGE");
                        }
                        direction = Direction.WEST;
                        current   = left;
                    }
                    if (InputHandler.playerRight())
                    {
                        if (direction == Direction.EAST && around[2, 1] != Tiles.WALL && around[2, 1] != Tiles.FAKEPASSAGE)
                        {
                            x     += 1;
                            moving = false;
                        }
                        if (around[2, 1] == Tiles.FAKEPASSAGE)
                        {
                            Console.WriteLine("CANT ENTER THIS PASSAGE");
                        }
                        direction = Direction.EAST;
                        current   = right;
                    }
                    if (InputHandler.playerAttack())
                    {
                        moving = false;
                        deal  += 100 + wealth;
                    }
                    if (InputHandler.playerSelect() && wealth > 0)
                    {
                        moving = false;
                        wealth--;
                        deal = -1;
                    }
                }
            }

            return(deal);
        }