Example #1
0
        public void arrowHandler(CollisionLine[] collLines, WumpusObject wumpus, PhysicsObject[] possibleColldingObjs, int[] connectedRooms)
        {
            collidingObjs = handleCollisions(collLines, possibleColldingObjs);

            for (int i = 0; i < collidingObjs.Length; i++)
            {
                if (collidingObjs[i].Equals("wumpus") || collidingObjs[i].Equals("bat") || collidingObjs[i].Equals("wall") || collidingObjs[i].Equals("fireball") || collidingObjs[i].Equals("rock"))
                {
                    alive = false;
                }
                Console.WriteLine(collidingObjs[i]);
            }

            if (wumpus.getRoomNumber() == getRoomNumber() && numberTimesRoomChange > 0)
            {
                wumpus.ground();
            }

            if (numberTimesRoomChange == 2)
            {
                alive = false;
            }

            tryRoomChange(connectedRooms);

            handleObj();
        }
Example #2
0
        //handles the player
        public void playerController(int[] connectedRooms, Point playerMovement, CollisionLine [] collLines, WumpusObject wumpus)
        {
            prevOrientation = orientation;
            reload++;

            setVelocity(playerMovement.Scale(maxSpeed));

            tryRoomChange(connectedRooms);
            string [] collisions = handleCollisions(collLines, getAllObjects());
            touchingBat = false;
            for (int i = 0; i < collisions.Length; i++)
            {
                if (collisions[i] == "bat")
                {
                    touchingBat = true;
                }
            }

            handleObj();
        }
Example #3
0
        public void generateMap()
        {
            //generate player start pos
            player = new PlayerObject(gen.Next(1, 31), new Point(0, 0), new Point(0, 0), new Point(0, 0), 100, roomheight, "player");

            //generate pos for bottomlessPits
            for (int i = 0; i < bottomlessPits.Length; i++)
            {
                int roomVal = gen.Next(1, 31);
                while (roomVal == player.getRoomNumber())
                {
                    roomVal = gen.Next(1, 31);
                }
                Point position = new Point(gen.Next(-300, 300), gen.Next(-300, 300));

                bottomlessPits[i] = new BottomlessPit(new Point(gen.Next(-300, 300), gen.Next(-300, 300)), 200, roomVal, "bottomless pit");
            }

            //
            for (int i = 0; i < rooms.Length; i++)
            {
                int         numRocks    = gen.Next(1, 5);
                List <Rock> rocksInRoom = new List <Rock>();
                for (int i1 = 0; i1 < numRocks; i1++)
                {
                    Point rockPos   = new Point(gen.Next(-400, 400), gen.Next(-400, 400));
                    bool  colliding = false;
                    while (colliding)
                    {
                        rockPos = new Point(gen.Next(-400, 400), gen.Next(-400, 400));

                        for (int i2 = 0; i2 < bottomlessPits.Length; i2++)
                        {
                            if (rockPos.distToPt(bottomlessPits[i].getPosition()) < 200)
                            {
                                colliding = true;
                            }
                        }
                    }

                    Rock newRock = new Rock(i + 1, rockPos, 50, "rock");
                    rocks.Add(newRock);
                    rocksInRoom.Add(newRock);
                }
                rooms[i] = new Room(c.getConnectedRooms(i + 1), roomheight, i + 1);
            }



            //generate start pos for bats
            for (int i = 0; i < bats.Length; i++)
            {
                int roomVal = gen.Next(1, 31);
                while (roomVal == player.getRoomNumber())
                {
                    roomVal = gen.Next(1, 31);
                }
                bats[i] = new BatObject(roomVal, new Point(0, 0), new Point(0, 0), new Point(0, 0), 100, "bat");
            }

            //generate Wumpus pos

            wumpus = new WumpusObject(8, new Point(0, 0), new Point(0, 0), new Point(0, 0), 150, "wumpus");

            int room;

            chests = new List <Chest>();
            trivia = new Trivia();
            for (int i = 0; i < 15; i++)
            {
                room = gen.Next(1, 31);
                int numChests = chests.Count;
                Console.WriteLine(i);
                for (int i1 = 0; i1 < numChests; i1++)
                {
                    if (room == chests[i1].getRoomNumber() || room == player.getRoomNumber())
                    {
                        i1   = 0;
                        room = gen.Next(1, 31);
                    }
                }

                Console.WriteLine("past the room selection");
                Chest chest     = null;
                bool  colliding = true;
                while (colliding)
                {
                    colliding = false;

                    chest = new Chest(new Point(gen.Next(-500, 500), gen.Next(-500, 500)), 100, room, gen.Next(6, 11), gen.Next(0, 3), trivia.getQuestion(), "chest", player.getInventory());

                    string[] collisions = chest.getCollisions(rocks.ToArray());
                    Console.WriteLine(chest.getPosition().toString());
                    for (int i1 = 0; i1 < collisions.Length; i1++)
                    {
                        if (collisions[i1].Equals("rock"))
                        {
                            colliding = true;
                            Console.WriteLine("colliding with rock");
                        }
                    }

                    for (int i1 = 0; i1 < bottomlessPits.Length; i1++)
                    {
                        if (bottomlessPits[i1].getPosition().distToPt(chest.getPosition()) < 200)
                        {
                            colliding = true;
                            Console.WriteLine("colliding with pit");
                        }
                    }
                }
                chests.Add(chest);
                Console.WriteLine("past position selection");
            }
        }