Esempio n. 1
0
    public InfoNewRoom PlayerDoorCollisions(Player character)
    {
        InfoNewRoom infomovingroom = new InfoNewRoom();

        infomovingroom.numRoom = -1;
        infomovingroom.Xplayer = -1;
        infomovingroom.Xplayer = -1;

        foreach (Door door in DoorList)
        {
            if (character.CollidesWith(door, Xmap))
            {
                infomovingroom.numRoom = door.GoTo;
                infomovingroom.Xplayer = door.XApparitionPlayer;
                infomovingroom.Yplayer = door.YApparitionPlayer;
            }
        }

        return(infomovingroom);
    }
Esempio n. 2
0
    public override void Show()
    {
        int keyPressed;



        /*This lines are to load the map from a file in the map class*/


        Mapper.WriteMap();
        Mapper.LoadMap(AllRooms);
        character.MoveTo(20, 20);

        do
        {
            keyPressed = hardware.KeyPressed();

            // 1. Draw everything
            hardware.ClearScreen();


            AllRooms[PosCurrentRoom].DrawPlayer(hardware, character);
            AllRooms[PosCurrentRoom].DrawAllShots(hardware);
            AllRooms[PosCurrentRoom].DrawAllBlocks(hardware);
            AllRooms[PosCurrentRoom].DrawAllEnemies(hardware);
            AllRooms[PosCurrentRoom].DrawAllUpgrades(hardware);
            AllRooms[PosCurrentRoom].DrawAllDoors(hardware);

            /*
             * AllRooms[PosCurrentRoom].DrawHud(hardware);
             */
            hardware.UpdateScreen();


            // 2. Move character from keyboard input
            OldXmap = AllRooms[PosCurrentRoom].Xmap;

            character.FillOldCoordinates();
            character.MovePlayer(hardware, AllRooms[PosCurrentRoom]);
            AllRooms[PosCurrentRoom].CreateNewShots(hardware, character);
            // 3. Move enemies and objects

            // 4. Check collisions and update game state



            // Attack of the enemies not finished yet
            AllRooms[PosCurrentRoom].EnemyCollisions();
            AllRooms[PosCurrentRoom].AttackPlayer(character);


            AllRooms[PosCurrentRoom].PlayerBlockCollisions(character, OldXmap);
            AllRooms[PosCurrentRoom].WeaponBlockCollisions();

            newroom = AllRooms[PosCurrentRoom].PlayerDoorCollisions(character);
            if (newroom.numRoom >= 0)
            {
                /*If the player collides with a door, he will move to the room where the door is pointing*/
                AllRooms[PosCurrentRoom].WeaponList.Clear();
                PosCurrentRoom = newroom.numRoom;
                character.MoveTo(newroom.Xplayer, newroom.Yplayer);
            }

            // 5. Pause game

            Thread.Sleep(1);
        }while (keyPressed != Hardware.KEY_ESC);
    }