예제 #1
0
파일: Room.cs 프로젝트: gabman15/upLink-exe
        public void ProcessCommand(string cmd)
        {
            string[] parts = cmd.Split(' ');
            switch (parts[0])
            {
            case "width":
                Width = int.Parse(parts[1]);
                break;

            case "height":
                Height = int.Parse(parts[1]);
                break;

            case "createobject":
            {
                Type       type     = GameObject.GetObjectFromName(parts[1]);
                Vector2    position = new Vector2(int.Parse(parts[2]), int.Parse(parts[3]));
                GameObject obj      = (GameObject)type.GetConstructor(new Type[] { typeof(Room), typeof(Vector2) }).Invoke(new object[] { this, position });
                obj.Layer = int.Parse(parts[4]);
                GameObjectList.Add(obj);
                GameObjectIntersectList.Add(false);
                break;
            }

            case "createsaw":
            {
                Vector2  position = new Vector2(int.Parse(parts[2]), int.Parse(parts[3]));
                Vector2  post1    = new Vector2(int.Parse(parts[4]), int.Parse(parts[5]));
                Vector2  post2    = new Vector2(int.Parse(parts[6]), int.Parse(parts[7]));
                SawBlade saw      = new SawBlade(this, position, post1, post2);
                saw.Layer = int.Parse(parts[8]);
                GameObjectList.Add(saw);
                GameObjectIntersectList.Add(false);
                break;
            }

            case "createtile":
            {
                Type     type     = GameTile.GetObjectFromName(parts[1]);
                Vector2  position = new Vector2(int.Parse(parts[2]), int.Parse(parts[3]));
                GameTile obj      = (GameTile)type.GetConstructor(new Type[] { typeof(Room), typeof(Vector2) }).Invoke(new object[] { this, position });
                obj.Layer = (float)int.Parse(parts[4]) / 100f;
                GameTileList.Add(obj);
                GameObjectIntersectList.Add(false);
                break;
            }

            case "background":
            {
                string spriteName = parts[1];
                AssetManager.RequestTexture(spriteName, (frame) =>
                    {
                        Console.WriteLine(spriteName);
                        background.Sprite  = new SpriteData();
                        SpriteData bSprite = background.Sprite;
                        bSprite.Size       = background.Size;
                        bSprite.Change(frame);
                    });
                break;
            }

            case "dialogue":
            {
                string          filename = parts[1];
                Vector2         position = new Vector2(int.Parse(parts[2]), int.Parse(parts[3]));
                DialogueHandler dialogue = new DialogueHandler(this, position, filename, Game.Content);
                dialogue.Layer = 0;
                GameObjectList.Add(dialogue);
                GameObjectIntersectList.Add(false);
                break;
            }
            }
        }