示例#1
0
        public bool IsEnemy(int x, int y, Player player, Hud hud)
        {
            for (int i = 0; i < enemies.Length; i++)
            {
                if (enemies[i].x == x && enemies[i].y == y)
                {
                    enemies[i].TakeDamage(enemies[i], player, hud);
                    return(true);
                }
            }

            return(false);
        }
示例#2
0
 public void UseInventory(Player player, ConsoleKeyInfo playerInput, Hud hud)
 {
     if (playerInput.KeyChar == '1')
     {
         if (invItem[0] != null)
         {
             invItem[0].Update(player, invItem[0], hud);
             invItem[0] = null;
         }
     }
     else if (playerInput.KeyChar == '2')
     {
         if (invItem[1] != null)
         {
             invItem[1].Update(player, invItem[1], hud);
             invItem[1] = null;
         }
     }
     else if (playerInput.KeyChar == '3')
     {
         if (invItem[2] != null)
         {
             invItem[2].Update(player, invItem[2], hud);
             invItem[2] = null;
         }
     }
     else if (playerInput.KeyChar == '4')
     {
         if (invItem[3] != null)
         {
             invItem[3].Update(player, invItem[3], hud);
             invItem[3] = null;
         }
     }
     else if (playerInput.KeyChar == '5')
     {
         if (invItem[4] != null)
         {
             invItem[4].Update(player, invItem[4], hud);
             invItem[4] = null;
         }
     }
     else if (playerInput.KeyChar == '6')
     {
         if (invItem[5] != null)
         {
             invItem[5].Update(player, invItem[5], hud);
             invItem[5] = null;
         }
     }
 }
示例#3
0
        public void TakeDamage(Player player, Enemy enemy, Hud hud)
        {
            player.health = player.health - enemy.attack;

            if (player.health <= 0)
            {
                player.health = 0;
                player.alive  = false;

                Hud.GameOver();
            }

            hud.ShowPlayerStats(player);
        }
示例#4
0
        public void Update(Map map, Player player, Enemy enemy, Hud hud)
        {
            if (enemy.alive == true)
            {
                Console.SetBufferSize(Console.LargestWindowWidth, Console.LargestWindowHeight);

                if (enemyType == 1)
                {
                    if (player.IsPlayerNear(enemy.x, enemy.y, player) == true)
                    {
                        player.TakeDamage(player, enemy, hud);
                        Console.Beep(100, 100);
                    }
                    else if (player.IsPlayerNear(enemy.x, enemy.y, player) == false)
                    {
                        EnemyAI1(map, enemy);
                    }
                }
                else if (enemyType == 2)
                {
                    if (player.IsPlayerNear(enemy.x, enemy.y, player) == true)
                    {
                        player.TakeDamage(player, enemy, hud);
                        Console.Beep(100, 100);
                    }
                    else if (player.IsPlayerFar(enemy.x, enemy.y, player) == true)
                    {
                        EnemyAI2(map, enemy, player);
                    }
                }
                else if (enemyType == 3)
                {
                    if (player.IsPlayerNear(enemy.x, enemy.y, player) == true)
                    {
                        player.TakeDamage(player, enemy, hud);
                        Console.Beep(100, 100);
                    }
                    else if (player.IsPlayerNear(enemy.x, enemy.y, player) == false)
                    {
                        EnemyAI3(map, enemy);
                    }
                }
            }
        }
示例#5
0
        public void Update(Player player, Hud hud, Inventory inventory)
        {
            for (int i = 0; i < ItemLimit; i++)
            {
                if (items[i].x == player.x && items[i].y == player.y && items[i].active == true)
                {
                    inventory.Update(items[i]);
                    hud.ItemCollected(items[i]);
                }
            }

            for (int i = 0; i < CoinLimit; i++)
            {
                if (coins[i].x == player.x && coins[i].y == player.y && coins[i].active == true)
                {
                    coins[i].Update(player, coins[i], hud);
                }
            }
        }
示例#6
0
        public void TakeDamage(Enemy enemy, Player player, Hud hud)
        {
            enemy.health = enemy.health - (player.attack + player.weaponAttack);

            if (enemy.health <= 0)
            {
                enemy.health = 0;
                enemy.alive  = false;
                Icon         = "";
                //Console.SetCursorPosition(enemy.x, enemy.y);
                //Console.Write(" ");
                enemy.x = 0;
                enemy.y = 0;

                player.exp  = player.exp + enemy.exp;
                player.gold = player.gold + enemy.gold;
            }

            hud.ShowEnemyStats(enemy);
        }
示例#7
0
        public void endGameCheck(Player player)
        {
            foreach (Enemy enemy in enemies)
            {
                if (enemy.alive == false)
                {
                    deathTally++;
                }
            }

            if (deathTally >= EnemyLimit)
            {
                player.alive = false;
                Hud.YouWin();
            }

            else
            {
                deathTally = 0;
            }
        }
示例#8
0
        public void Update(Map map, Player player, EnemyManager enemyManager, Camera camera, Hud hud, Inventory inventory)
        {
            Console.CursorVisible = false;
            Console.SetWindowSize(camera.Xend + 20, hud.currentHudLine + 2);
            Console.SetWindowPosition(0, 0);

            if (player.exp >= player.levelUpLimit)
            {
                player.exp = player.exp - player.levelUpLimit;
                player.level++;
                player.attack       = (int)(player.attack * 1.5d);
                player.levelUpLimit = (int)(player.levelUpLimit * 1.5d);

                hud.PlayerLevelUp(player);
            }

            while (Console.KeyAvailable)
            {
                Console.ReadKey(true);
            }

            ConsoleKeyInfo input;

            input = Console.ReadKey(true);

            if (input.KeyChar == 'w')
            {
                if (Movement(x, y - speed, map, player, enemyManager, hud) == true)
                {
                    if (GameManager.scrollingCamera == false)
                    {
                        camera.offsetY--;
                    }
                }
            }
            else if (input.KeyChar == 'd')
            {
                if (Movement(x + speed, y, map, player, enemyManager, hud) == true)
                {
                    if (GameManager.scrollingCamera == false)
                    {
                        camera.offsetX++;
                    }
                }
            }
            else if (input.KeyChar == 's')
            {
                if (Movement(x, y + speed, map, player, enemyManager, hud) == true)
                {
                    if (GameManager.scrollingCamera == false)
                    {
                        camera.offsetY++;
                    }
                }
            }
            else if (input.KeyChar == 'a')
            {
                if (Movement(x - speed, y, map, player, enemyManager, hud) == true)
                {
                    if (GameManager.scrollingCamera == false)
                    {
                        camera.offsetX--;
                    }
                }
            }
            else
            {
                inventory.UseInventory(player, input, hud);
            }

            Console.SetBufferSize(Console.LargestWindowWidth, Console.LargestWindowHeight);
            wallet.Update(player);
        }
示例#9
0
        public bool Movement(int x, int y, Map map, Player player, EnemyManager enemyManager, Hud hud)
        {
            if (map.IsFloor(y, x) == true)
            {
                if (enemyManager.IsEnemy(x, y, player, hud) == true)
                {
                    Console.SetBufferSize(Console.LargestWindowWidth, Console.LargestWindowHeight);
                    Console.Beep(800, 200);
                    return(false);
                }
                else
                {
                    Console.SetBufferSize(Console.LargestWindowWidth, Console.LargestWindowHeight);
                    player.y = y;
                    player.x = x;
                    return(true);
                }
            }
            else if (hasKey == true)
            {
                if (map.IsLockedDoor(y, x) == true)
                {
                    player.y = y;
                    player.x = x;
                    return(true);
                }

                return(false);
            }
            else
            {
                Collision(); return(false);
            }
        }