Exemple #1
0
 public void moveDown()
 {
     Direction = EDirection.South;
     Texture   = TexturePool.GetTexture("robot_d");
     KeyPressedDelay(Keys.Down, 0, 1);
 }
Exemple #2
0
 public void moveUp()
 {
     Direction = EDirection.North;
     Texture   = TexturePool.GetTexture("robot_u");
     KeyPressedDelay(Keys.Up, 0, -1);
 }
Exemple #3
0
 public void moveRight()
 {
     Direction = EDirection.East;
     Texture   = TexturePool.GetTexture("robot_r");
     KeyPressedDelay(Keys.Right, 1, 0);
 }
Exemple #4
0
 public void moveLeft()
 {
     Direction = EDirection.West;
     Texture   = TexturePool.GetTexture("robot_l");
     KeyPressedDelay(Keys.Left, -1, 0);
 }
Exemple #5
0
        public static void LoadRoom(string fileName)
        {
            var  map     = new TmxMap(fileName + ".tmx");
            int  width   = map.Width;
            int  height  = map.Height;
            Room newRoom = new Room(fileName, width, height);

            foreach (TmxTileset tmxT in map.Tilesets)
            {
                newRoom.AddTileSheet(tmxT.Name, TexturePool.GetTileSheet(tmxT.Name));
                newRoom.TileSheets[tmxT.Name].SetGID(tmxT.FirstGid);
            }
            TileSheet currSheet = null;

            foreach (TmxLayer tmxL in map.Layers)
            {
                Tile[,] TileLayer = new Tile[width, height];
                switch (tmxL.Name)
                {
                case "Ground":

                    foreach (TmxLayerTile tile in tmxL.Tiles)
                    {
                        int lastGID = 0;
                        int thisGID = 0;
                        if (tile.Gid != 0)
                        {
                            foreach (KeyValuePair <string, TileSheet> kvp in newRoom.TileSheets)
                            {
                                thisGID = kvp.Value.GID;
                                if (tile.Gid > thisGID)
                                {
                                    currSheet = kvp.Value;
                                }
                            }
                            TileLayer[tile.X, tile.Y] = new TileVisible(newRoom, currSheet, tile.Gid - currSheet.GID, tile.X, tile.Y, TileType.ground);
                        }
                    }
                    break;

                case "Interact":
                    foreach (TmxLayerTile tile in tmxL.Tiles)
                    {
                        int lastGID = 0;
                        int thisGID = 0;
                        if (tile.Gid != 0)
                        {
                            foreach (KeyValuePair <string, TileSheet> kvp in newRoom.TileSheets)
                            {
                                thisGID = kvp.Value.GID;
                                if (tile.Gid >= thisGID)
                                {
                                    currSheet = kvp.Value;
                                }
                            }
                            TileLayer[tile.X, tile.Y] = new TileVisible(newRoom, currSheet, tile.Gid - currSheet.GID, tile.X, tile.Y, TileType.collider);
                        }
                        else
                        {
                            TileLayer[tile.X, tile.Y] = new TileVisible(newRoom, currSheet, tile.Gid - 1, tile.X, tile.Y, TileType.other);
                        }
                    }
                    break;
                }
                newRoom.AddTileLayer(tmxL.Name, new TileLayer(newRoom, TileLayer));
            }
            foreach (TmxObjectGroup tmxO in map.ObjectGroups)
            {
                Tile[,] TileLayer = new Tile[width, height];
                switch (tmxO.Name)
                {
                case "Events":
                    foreach (TmxObject obj in tmxO.Objects)
                    {
                        var type = obj.Properties["Type"];
                        switch (type)
                        {
                        case "Teleporter":
                            TileLayer[(int)obj.X / 32, (int)obj.Y / 32] = new TileTeleporter(newRoom, obj.Properties["room"], (int)obj.X / 32, (int)obj.Y / 32, Convert.ToInt32(obj.Properties["X"]), Convert.ToInt32(obj.Properties["Y"]), TileType.teleporter);
                            break;

                        case "Readable":
                            List <string> text = new List <string>();
                            for (int i = 0; i < 10; i++)
                            {
                                if (obj.Properties.ContainsKey("text" + i.ToString()))
                                {
                                    text.Add(obj.Properties["text" + i.ToString()]);
                                }
                            }
                            TileLayer[(int)obj.X / 32, (int)obj.Y / 32] = new TileSign(newRoom, text, (int)obj.X / 32, (int)obj.Y / 32, TileType.readable);
                            break;
                        }
                    }
                    break;
                }
                newRoom.AddTileLayer(tmxO.Name, new TileLayer(newRoom, TileLayer));
            }
            //Maybe change to Just add to RoomManager
            newRoom.Name = Path.GetFileName(newRoom.Name);
            RoomManager.AddRoom(newRoom);
        }
Exemple #6
0
 public override void Draw(SpriteBatch spriteBatch)
 {
     spriteBatch.Draw(TexturePool.GetTexture("dialogue"), Position, Color.White);
     spriteBatch.DrawString(TexturePool.GetFont("dialogue_font"), Text, new Vector2(20, 20), Color.Black);
 }