Esempio n. 1
0
        public int keyInput(Maps currentMap)
        {
            ConsoleKeyInfo keyInfo = Console.ReadKey(true);
            Maps.objects feedback;
            switch (keyInfo.Key)
            {
                case ConsoleKey.W:
                    if ((feedback = currentMap.update(x, y, x - 1, y, 0)) != Maps.objects.CANTWALK)
                    {
                        if (feedback != Maps.objects.ENEMYSKELETONKING)
                        {
                            this.x--;

                        }
                        return adjustPlayer(feedback, currentMap);
                    }
                    break;
                case ConsoleKey.S:
                    if ((feedback = currentMap.update(x, y, x + 1, y, 0)) != Maps.objects.CANTWALK)
                    {
                        if (feedback != Maps.objects.ENEMYSKELETONKING)
                        {
                            this.x++;

                        }
                        return adjustPlayer(feedback, currentMap);
                    }
                    break;
                case ConsoleKey.A:
                    if ((feedback = currentMap.update(x, y, x, y - 1, 0)) != Maps.objects.CANTWALK)
                    {
                        if (feedback != Maps.objects.ENEMYSKELETONKING)
                        {
                            this.y--;

                        }
                        return adjustPlayer(feedback, currentMap);
                    }
                    break;
                case ConsoleKey.D:
                    if ((feedback = currentMap.update(x, y, x, y + 1, 0)) != Maps.objects.CANTWALK)
                    {
                        if (feedback != Maps.objects.ENEMYSKELETONKING)
                        {
                            this.y++;

                        }

                        return adjustPlayer(feedback, currentMap);
                    }
                    break;

                case ConsoleKey.Escape:

                    Engine.running = false;

                    break;

                case ConsoleKey.H:
                    Console.Clear();
                    Console.WriteLine("                                                                           ");
                    Console.WriteLine("         Press \"W\" to Move Up                                            ");
                    Console.WriteLine("         Press \"S\" to Move Down                                          ");
                    Console.WriteLine("         Press \"A\" to Move Left                                          ");
                    Console.WriteLine("         Press \"D\" to Move Right                                         ");
                    Console.WriteLine("         Press \"B\" to Buy one Health for 10 Gold                         ");
                    Console.WriteLine("         Press \"O\" to insert your Cheat                                  ");
                    Console.WriteLine("         Press \"ESC\" to Exit the game                                    ");
                    Console.WriteLine("                                                                           ");
                    Console.WriteLine("         Rougy is created by Julian Hopp and Daniel Lause.                 ");
                    Console.ReadKey(true);
                    Console.Clear();

                    break;

                case ConsoleKey.B:
                    if (goldCounter >= 10)
                    {
                        healthCounter++;
                        goldCounter -= 10;
                    }

                    break;

                case ConsoleKey.O:
                    Console.Clear();
                    Console.WriteLine();
                    Console.WriteLine();
                    Console.WriteLine("      /\\     ");
                    Console.WriteLine("     /--\\    ");
                    Console.WriteLine("    /_\\/_\\  ");
                    Console.WriteLine();
                    Console.WriteLine();
                    Console.WriteLine("Enter your Cheat: ");
                    String read = Console.ReadLine();
                    if (read == "key")
                    {
                        hasKey = true;
                    }
                    if (read == "gold")
                    {
                        goldCounter = 999;
                    }
                    if (read == "killurself")
                    {
                        healthCounter = 0;
                    }
                    if (read == "winwin")
                    {
                        hasTriforce = true;
                    }

                    break;

                default:
                    return 5;
            }
            return 5;
        }
Esempio n. 2
0
        public int spawn(Maps currentMap)
        {
            newSpawnPoint();
            canSpawn = false;
            while (alive)
            {
            Maps.objects feedback;

            i = rnd.Next(1, 5);
            //if (player.x > x)
            //{
            //    if ((feedback = currentMap.update(x, y, x - 1, y, 1)) == Maps.objects.CANTWALK)//|| feedback == Maps.objects.PLAYER)
            //    {
            //        this.x -= 1;
            //        return adjustEnemy(feedback, currentMap);
            //    }
            //}
            //else if (player.x < x)
            //{
            //    if ((feedback = currentMap.update(x, y, x + 1, y, 1)) == Maps.objects.CANTWALK)//|| feedback == Maps.objects.PLAYER)
            //    {
            //        this.x += 1;
            //        return adjustEnemy(feedback, currentMap);
            //    }
            //}
            //else if (player.y > y)
            //{
            //    if ((feedback = currentMap.update(x, y, x, y - 1, 1)) == Maps.objects.CANTWALK)//|| feedback == Maps.objects.PLAYER)
            //    {
            //        this.y -= 1;
            //        return adjustEnemy(feedback, currentMap);
            //    }
            //}
            //else if (player.y < y)
            //{
            //    if ((feedback = currentMap.update(x, y, x, y + 1, 1)) == Maps.objects.CANTWALK)//|| feedback == Maps.objects.PLAYER)
            //    {
            //        this.y += 1;
            //        return adjustEnemy(feedback, currentMap);
            //    }
            //}

            switch (i)
            {
                case 1:
                    if ((feedback = currentMap.update(x, y, x - 1, y, (int)type)) == Maps.objects.EMPTY || feedback == Maps.objects.PLAYER)
                    {
                            this.x--;
                        return adjustEnemy(feedback, currentMap);
                    }
                    break;
                case 2:
                    if ((feedback = currentMap.update(x, y, x + 1, y, (int)type)) == Maps.objects.EMPTY || feedback == Maps.objects.PLAYER)
                    {
                            this.x++;
                        return adjustEnemy(feedback, currentMap);
                    }
                    break;
                case 3:
                    if ((feedback = currentMap.update(x, y, x, y - 1, (int)type)) == Maps.objects.EMPTY || feedback == Maps.objects.PLAYER)
                    {
                            this.y--;
                        return adjustEnemy(feedback, currentMap);
                    }

                    break;
                case 4:
                    if ((feedback = currentMap.update(x, y, x, y + 1, (int)type)) == Maps.objects.EMPTY || feedback == Maps.objects.PLAYER)
                    {
                            this.y++;
                        return adjustEnemy(feedback, currentMap);
                    }
                    break;

                default:
                    return 5;
            }
            return 5;
            }
            return 1100;
        }