コード例 #1
0
ファイル: TextBox.cs プロジェクト: tojuhaka/HakaGame
        public TextBox(SpriteFont spriteFont, IEContentManager Content, SpriteBatch spriteBatch)
        {
            this.spriteFont = spriteFont;
            this.content = Content;

            textboxTexture = Content.Load<Texture2D>("Content/GUI/textbox");
            cursor = Content.Load<Texture2D>("Content/GUI/cursor");
            blink = false;
            text = "";
            this.Visible = true;
            this.Enabled = true;
            this.TabStop = true;
            this.HasFocus = false;
            this.spriteBatch = spriteBatch;
        }
コード例 #2
0
ファイル: TileLoader.cs プロジェクト: tojuhaka/HakaGame
        // loads the tiles from xml-file generated by TileMapEditor TODO: Content pipeline
        public TileLoader(string filename, IEContentManager content)
        {
            this.content = content;
            list = new TileList();
            input = new TInput();
            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.Load(filename);
            //TODO:
                foreach (XmlNode node in xmlDoc.DocumentElement.ChildNodes) // tilesetFile nodes
                {
                    //TODO Make tilesets
                    if (node.Name == "tiles") // if node is <tiles>
                    {
                        foreach (XmlNode imageTileNode in node.ChildNodes) // <imageTiles>
                        {

                            int id = Int32.Parse(imageTileNode.Attributes["id"].Value);
                            int width = Int32.Parse(imageTileNode.Attributes["width"].Value);
                           int height = Int32.Parse(imageTileNode.Attributes["height"].Value);

                            foreach (XmlNode imageTileNodes in imageTileNode.ChildNodes)
                            {
                                if (imageTileNodes.Name == "image")
                                {
                                    string file = imageTileNodes.Attributes["file"].Value;
                                    string[] contentName =  file.Split('.');

                                    try
                                    {
                                        file = contentName[0];
                                    }
                                    catch
                                    {
                                        throw new Exception("Invalid picture name at " + file);
                                    }
                                    texture = content.Load<Texture2D>("Content/images/" + contentName[0]);

                                    tile = new Tile(texture,id);
                                    list.Add(tile);
                                }

                                //TODO Optimize tilesets
                                if (imageTileNodes.Name == "tilesetImage")
                                {
                                    string file = imageTileNodes.Attributes["file"].Value;
                                    string[] contentName = file.Split('.');

                                    try
                                    {
                                        file = contentName[0];
                                    }
                                    catch
                                    {
                                        throw new Exception("Invalid picture name at " + file);
                                    }

                                    //Loads the whole texture. for optimizing just load the tileset
                                    //Once then use the same texture in all tiles
                                    texture = content.Load<Texture2D>("Content/images/" + contentName[0]);
                                    int x = Int32.Parse(imageTileNodes.Attributes["posX"].Value);
                                    int y = Int32.Parse(imageTileNodes.Attributes["posY"].Value);

                                    Rectangle tilesetPart = new Rectangle(x, y, width, height);
                                    tile = new Tile(texture, id, tilesetPart);
                                    tile.IsPartOfTileset = true;
                                    list.Add(tile);
                                }
                            }

                            //TODO: Check for bugs
                            //Load nulltiles with collision
                            if (imageTileNode.Name == "nullTile")
                            {
                                foreach (XmlNode imageTileNodes in imageTileNode.ChildNodes)
                                {
                                    if (imageTileNodes.Name == "collision")
                                    {
                                        string collision = imageTileNodes.Attributes["area"].Value;
                                        if (collision != "none")
                                        {
                                            tile = new Tile(CollisionType.Unpassable);
                                        }
                                        else
                                        {
                                            tile = new Tile(CollisionType.Passable);
                                        }
                                        tile.TileID = id;
                                        list.Add(tile);
                                    }
                                }

                            }
                        }
                    }
                }
        }
コード例 #3
0
ファイル: Tile.cs プロジェクト: tojuhaka/HakaGame
 // If texture is null, we should load the texture with file name given
 // if filename is null, then there is something wrong TODO: fix that bug
 public void Load(IEContentManager content)
 {
     texture = content.Load<Texture2D>(filename);
 }