예제 #1
0
        //specific AI
        public override void Update(Map map, Player player, Camera camera, ItemManager itemManager, EnemyManager enemyManager)
        {
            if (vitalStatus == VitalStatus.Alive)
            {
                if (player.isPlayerAt(xLoc, yLoc - 1) == true)
                {
                    player.TakeDamage(attackDamage); Console.Beep(400, 100);
                }
                else if (player.isPlayerAt(xLoc - 1, yLoc) == true)
                {
                    player.TakeDamage(attackDamage); Console.Beep(400, 100);
                }
                else if (player.isPlayerAt(xLoc + 1, yLoc) == true)
                {
                    player.TakeDamage(attackDamage); Console.Beep(400, 100);
                }
                else if (player.isPlayerAt(xLoc, yLoc + 1) == true)
                {
                    player.TakeDamage(attackDamage); Console.Beep(50, 500);
                }

                //else if (player.isPlayerNear(xLoc, yLoc - 5) == true) { SwitchDirection(Moving.Up, normal); }
                //else if (player.isPlayerNear(xLoc - 5, yLoc) == true) { SwitchDirection(Moving.Left, normal); }
                //else if (player.isPlayerNear(xLoc + 5, yLoc) == true) { SwitchDirection(Moving.Right, normal); }
                //else if (player.isPlayerNear(xLoc, yLoc + 5) == true) { SwitchDirection(Moving.Down, normal); }

                else
                {
                    int pos = rnd.Next(1, 6);
                    if (pos == 2)
                    {
                        Move(Moving.Left);
                    }
                    if (pos == 3)
                    {
                        Move(Moving.Right);
                    }
                    if (pos == 4)
                    {
                        Move(Moving.Down);
                    }
                    if (pos == 5)
                    {
                        Move(Moving.Up);
                    }
                }

                base.Update(map, player, camera, itemManager, enemyManager);
            }
            //I think I have said it to much already.. see other enemy classes.....
            else
            {
                SwitchVitalStatus(VitalStatus.Dead);
                if (!gaveGold)
                {
                    player.GainMoney(goldAmountToGive);
                    gaveGold = true;
                }
            }
        }
예제 #2
0
        public override void Update(Map map, Player player, Camera camera, ItemManager itemManager, EnemyManager enemyManager)
        {
            //specific AI
            if (vitalStatus == VitalStatus.Alive)
            {
                if (player.isPlayerAt(xLoc, yLoc - 1) == true)
                {
                    player.TakeDamage(attackDamage); Console.Beep(700, 100);
                }
                else if (player.isPlayerAt(xLoc - 1, yLoc) == true)
                {
                    player.TakeDamage(attackDamage); Console.Beep(700, 100);
                }
                else if (player.isPlayerAt(xLoc + 1, yLoc) == true)
                {
                    player.TakeDamage(attackDamage); Console.Beep(700, 100);
                }
                else if (player.isPlayerAt(xLoc, yLoc + 1) == true)
                {
                    player.TakeDamage(attackDamage); Console.Beep(700, 100);
                }
                else
                {
                    int pos = rnd.Next(1, 8);
                    if (pos == 2)
                    {
                        Move(Moving.Left);
                    }
                    if ((pos >= 3) && (pos <= 4))
                    {
                        Move(Moving.Right);
                    }
                    if ((pos >= 5) && (pos <= 6))
                    {
                        Move(Moving.Up);
                    }
                    if (pos == 7)
                    {
                        Move(Moving.Down);
                    }
                }

                base.Update(map, player, camera, itemManager, enemyManager);
            }
            //"if its not alive its dead"
            else
            {
                SwitchVitalStatus(VitalStatus.Dead);
                if (!gaveGold)
                {
                    player.GainMoney(goldAmountToGive);
                    gaveGold = true;
                }
            }
        }
예제 #3
0
        public void Update(Map map, EnemyManager enemyManager, ItemManager itemManager, GameOver gameOver, Inventory inventory, ShopManager shopManager)
        {
            Console.CursorVisible = false;
            ConsoleKey keyPressed = Console.ReadKey(true).Key;

            if (vitalStatus == VitalStatus.Alive)
            {
                if (keyPressed == ConsoleKey.W)
                {
                    //collision
                    if (wallExist = map.IsWallAt(xLoc, yLoc - 1))
                    {
                        //do nothing
                    }
                    else if (enemyExist = enemyManager.IsEnemyAt(xLoc, yLoc - 1))
                    {
                        enemyManager.CheckEnemies(xLoc, yLoc - 1, attackDamage);
                    }
                    else if (itemExist = itemManager.IsItemAt(xLoc, yLoc - 1) && inventory.settingUpInventory == false)
                    {
                        if (inventory.IsInventorySlotAvailable() == true)
                        {
                            itemManager.CheckAndPickupItems(xLoc, yLoc - 1);
                        }
                        else
                        {
                            inventory.inventoryIsFull = true;
                        }
                    }
                    else
                    {
                        previousXLoc = xLoc;
                        previousYLoc = yLoc;
                        yLoc         = yLoc - 1;
                    }
                }
                if (keyPressed == ConsoleKey.A)
                {
                    if (wallExist = map.IsWallAt(xLoc - 1, yLoc))
                    {
                        //do nothing
                    }
                    else if (enemyExist = enemyManager.IsEnemyAt(xLoc - 1, yLoc))
                    {
                        enemyManager.CheckEnemies(xLoc - 1, yLoc, attackDamage);
                    }
                    else if (itemExist = itemManager.IsItemAt(xLoc - 1, yLoc))
                    {
                        if (inventory.IsInventorySlotAvailable() == true)
                        {
                            itemManager.CheckAndPickupItems(xLoc - 1, yLoc);
                        }
                        else
                        {
                            inventory.inventoryIsFull = true;
                        }
                    }
                    else
                    {
                        previousXLoc = xLoc;
                        previousYLoc = yLoc;
                        xLoc         = xLoc - 1;
                    }
                }
                if (keyPressed == ConsoleKey.S)
                {
                    if (wallExist = map.IsWallAt(xLoc, yLoc + 1))
                    {
                        //do nothing
                    }
                    else if (enemyExist = enemyManager.IsEnemyAt(xLoc, yLoc + 1))
                    {
                        enemyManager.CheckEnemies(xLoc, yLoc + 1, attackDamage);
                    }
                    else if (itemExist = itemManager.IsItemAt(xLoc, yLoc + 1))
                    {
                        if (inventory.IsInventorySlotAvailable() == true)
                        {
                            itemManager.CheckAndPickupItems(xLoc, yLoc + 1);
                        }
                        else
                        {
                            inventory.inventoryIsFull = true;
                        }
                    }
                    else
                    {
                        previousXLoc = xLoc;
                        previousYLoc = yLoc;
                        yLoc         = yLoc + 1;
                    }
                }
                if (keyPressed == ConsoleKey.D)
                {
                    if (wallExist = map.IsWallAt(xLoc + 1, yLoc))
                    {
                        //do nothing
                    }
                    else if (enemyExist = enemyManager.IsEnemyAt(xLoc + 1, yLoc))
                    {
                        enemyManager.CheckEnemies(xLoc + 1, yLoc, attackDamage);
                    }
                    else if (itemExist = itemManager.IsItemAt(xLoc + 1, yLoc))
                    {
                        if (inventory.IsInventorySlotAvailable() == true)
                        {
                            itemManager.CheckAndPickupItems(xLoc + 1, yLoc);
                        }
                        else
                        {
                            inventory.inventoryIsFull = true;
                        }
                    }
                    else
                    {
                        previousXLoc = xLoc;
                        previousYLoc = yLoc;
                        xLoc         = xLoc + 1;
                    }
                }
                if (keyPressed == ConsoleKey.I)
                {
                    inventory.inventoryIsOpen = true;
                }
                //determines win
                if (collectedValuables >= itemManager.valuableCount)
                {
                    gameOver.gameOverWin = true;
                }
            }
            else
            {
                SwitchVitalStatus(VitalStatus.Dead);
            }
            //determines loss...
            if (vitalStatus == VitalStatus.Dead)
            {
                gameOver.gameOverLoss = true;
            }
        }
예제 #4
0
 public void InitShopFromWorldLoc(char[,] world, int X, int Y, ItemManager itemManager, Player player, Camera cam, Inventory inventory, EnemyManager enemyManager)
 {
     if (shopCount > shopCap - 1)
     {
         return;
     }
     if (world[X, Y] == Global.shopAppearance)
     {
         shops[shopCount] = new Shop(X, Y, Global.shopXLoc, Global.shopYLoc, true, Global.shopItemAmount, itemManager, player, cam, inventory, enemyManager); shopCount = shopCount + 1;
     }
 }
예제 #5
0
 //updates each enemys
 public void UpdateEnemies(Map map, Player player, Camera camera, ItemManager itemManager, EnemyManager enemyManager)
 {
     for (int i = 0; i < enemyCount; i++)
     {
         enemies[i].Update(map, player, camera, itemManager, enemyManager);
     }
 }