void SpawnTestUnits()
    {
        string[] recipes = new string[] {
            "Lightning",
            "Izrad",
            "Sils",
            "Enemy Rogue",
            "Enemy Warrior",
            "Enemy Wizard",
        };

        GameObject unitContainer = new GameObject("units");

        unitContainer.transform.SetParent(owner.transform);

        List <WorldTile> locations = new List <WorldTile>(board.tiles.Values);

        for (int i = 0; i < recipes.Length; ++i)
        {
            int        level      = UnityEngine.Random.Range(9, 12);
            GameObject instance   = UnitFactory.Create(recipes[i], level);
            int        random     = UnityEngine.Random.Range(0, locations.Count);
            WorldTile  randomTile = locations[random];
            locations.RemoveAt(random);
            Unit unit = instance.GetComponent <Unit>();
            unit.Place(randomTile);
            unit.dir = (Directions)UnityEngine.Random.Range(0, 4);
            unit.Match();
            units.Add(unit);
        }
        SelectTile(units[0].tile.pos);
    }
Ejemplo n.º 2
0
        protected override void Run(Session session, Actor_CreateUnits message)
        {
            // 加载Unit资源
            ResourcesComponent resourcesComponent = Game.Scene.GetComponent <ResourcesComponent>();

            resourcesComponent.LoadBundle($"Unit.unity3d");

            UnitComponent unitComponent = Game.Scene.GetComponent <UnitComponent>();

            foreach (UnitInfo unitInfo in message.Units)
            {
                if (unitComponent.Get(unitInfo.UnitId) != null)
                {
                    continue;
                }
                Unit unit = UnitFactory.Create(unitInfo.UnitId);
                unit.Position = new Vector3(unitInfo.X / 1000f, 0, unitInfo.Z / 1000f);
                unit.IntPos   = new VInt3(unitInfo.X, 0, unitInfo.Z);

                if (PlayerComponent.Instance.MyPlayer.UnitId == unit.Id)
                {
                    Game.Scene.GetComponent <CameraComponent>().Unit = unit;
                }
            }

            Hotfix.Scene.AddComponent <OperaComponent>();
        }
        private void SpawnTestUnits()
        {
            string[] recipes =
            {
                "Ramza",
                "Delita",
                "Ovelia",
                "Enemy Warrior",
                "Enemy Rogue",
                "Enemy Wizard"
            };

            var locations = new List <Tile>(board.tiles.Values);

            for (int i = 0; i < recipes.Length; ++i)
            {
                int        level    = UnityEngine.Random.Range(9, 12);
                GameObject instance = UnitFactory.Create(recipes[i], level);
                instance.transform.parent = owner.board.unitsContainer;

                int  random     = UnityEngine.Random.Range(0, locations.Count);
                Tile randomTile = locations[random];
                locations.RemoveAt(random);

                Unit unit = instance.GetComponent <Unit>();
                unit.Place(randomTile);
                unit.dir = (Directions)UnityEngine.Random.Range(0, 4);
                unit.Match();

                units.Add(unit);
            }

            SelectTile(units[0].tile.pos);
        }
Ejemplo n.º 4
0
        // 场景切换协程
        public static async ETTask SceneChangeTo(Scene zoneScene, string sceneName, long sceneInstanceId)
        {
            zoneScene.RemoveComponent <AIComponent>();

            CurrentScenesComponent currentScenesComponent = zoneScene.GetComponent <CurrentScenesComponent>();

            currentScenesComponent.Scene?.Dispose(); // 删除之前的CurrentScene,创建新的
            Scene         currentScene  = SceneFactory.CreateCurrentScene(sceneInstanceId, zoneScene.Zone, sceneName, currentScenesComponent);
            UnitComponent unitComponent = currentScene.AddComponent <UnitComponent>();

            // 可以订阅这个事件中创建Loading界面
            Game.EventSystem.Publish(new EventType.SceneChangeStart()
            {
                ZoneScene = zoneScene
            });

            // 等待CreateMyUnit的消息
            WaitType.Wait_CreateMyUnit waitCreateMyUnit = await zoneScene.GetComponent <ObjectWait>().Wait <WaitType.Wait_CreateMyUnit>();

            M2C_CreateMyUnit m2CCreateMyUnit = waitCreateMyUnit.Message;
            Unit             unit            = UnitFactory.Create(currentScene, m2CCreateMyUnit.Unit);

            unitComponent.Add(unit);

            zoneScene.RemoveComponent <AIComponent>();

            Game.EventSystem.Publish(new EventType.SceneChangeFinish()
            {
                ZoneScene = zoneScene, CurrentScene = currentScene
            });

            // 通知等待场景切换的协程
            zoneScene.GetComponent <ObjectWait>().Notify(new WaitType.Wait_SceneChangeFinish());
        }
Ejemplo n.º 5
0
    public void FixedUpdate()
    {
        if (ConstructingUnit != null)
        {
            ConstructionTimeLeft -= Time.deltaTime;

            if (ConstructionTimeLeft <= 0f)
            {
                ConstructingUnit.gameObject.SetActive(true);
                ConstructingUnit = null;

                GetComponent <SpriteRenderer>().sprite = CompletedSprite;
            }
        }

        if (QueueTimeLeft > 0)
        {
            QueueTimeLeft -= Time.fixedDeltaTime;
        }
        else if (CurrentQueuedItem != QueueType.None)
        {
            var coords   = CordUtil.WorldToTile(transform.position);
            var freespot = _map.FindNextFreeTile(coords.First, coords.Second);
            _unitfactory.Create(QueuedUnit, PlayerOwner, freespot.First, freespot.Second - 2);
            CurrentQueuedItem = QueueType.None;
        }

        if (HP <= 0)
        {
            //Building dies
            Destroy(gameObject);
        }
    }
Ejemplo n.º 6
0
        protected override async void Run(Session session, Actor_CreateUnits message)
        {
            ETModel.Game.Scene.GetComponent <LatencyComponent>().AddAMsgLan(message.Time - TimeHelper.GetCurrentTimeUnix());
            Debug.Log("CreatUnit");
            UnitComponent unitComponent = ETModel.Game.Scene.GetComponent <UnitComponent>();

            for (int i = 0; i < message.Units.Count; i++)
            {
                if (unitComponent.Get(message.Units[i].UnitId) != null)
                {
                    //UpdateInfo;
                    continue;
                }
                else
                {
                    Unit unit = UnitFactory.Create(message.Units[i].UnitId, "TestName");
                    unit.Position  = new Vector3(message.Units[i].X / 1000f, 0, message.Units[i].Z / 1000f);
                    unit.IntPos    = new VInt3(message.Units[i].X, 0, message.Units[i].Z);
                    unit.mPlayerID = message.Units[i].PlayerId;
                }
            }
            //Add FrameCompoont SendStart proto
            //TODO CHECK NET STATES AND SET FREAME TYPE
            //Game.Scene.AddComponent<LockFrameComponent>();
            M2C_ReadyStartGame response = (M2C_ReadyStartGame)await ETModel.SessionComponent.Instance.Session.Call(new C2M_ReadyStartGame()
            {
            });

            Debug.Log(response.Message);
            //    Game.Scene.GetComponent<LockFrameComponent>().StartGame();
        }
Ejemplo n.º 7
0
    //CODE FOR TESTING ONLY, creates units manually
    void SpawnTestUnits()
    {
        string[] recipes = new string[]
        {
            "Alaois",
            "Hania",
            "Kamau",
            "Enemy Rogue",
            "Enemy Warrior",
            "Enemy Wizard"
        };

        List <Tile> locations = new List <Tile>(board.tiles.Values);

        for (int i = 0; i < recipes.Length; ++i)
        {
            int        level    = 1;
            GameObject instance = UnitFactory.Create(recipes[i], level);

            int  random     = UnityEngine.Random.Range(0, locations.Count);
            Tile randomTile = locations[random];
            locations.RemoveAt(random);

            Unit unit = instance.GetComponent <Unit>();
            unit.Place(randomTile);
            unit.dir = (Directions)UnityEngine.Random.Range(0, 4);
            unit.Match();

            units.Add(unit);
        }

        SelectTile(units[0].tile.pos);
    }
Ejemplo n.º 8
0
        // 场景切换协程
        public static async ETTask SceneChangeTo(Scene zoneScene, string sceneName, long sceneInstanceId)
        {
            // zoneScene.RemoveComponent<AIComponent>();
            zoneScene.AddComponent <KeyCodeComponent>();
            CurrentScenesComponent currentScenesComponent = zoneScene.GetComponent <CurrentScenesComponent>();

            currentScenesComponent.Scene?.Dispose(); // 删除之前的CurrentScene,创建新的
            Scene currentScene = SceneFactory.CreateCurrentScene(sceneInstanceId, zoneScene.Zone, sceneName, currentScenesComponent);

            currentScene.AddComponent <UnitComponent>();
            currentScene.AddComponent <AOISceneComponent, int>(6);
            // 可以订阅这个事件中创建Loading界面
            using (ListComponent <ETTask> tasks = ListComponent <ETTask> .Create())
            {
                tasks.Add(WaitChangeScene(zoneScene, sceneName)); //等收到消息并且地图创建完成
                tasks.Add(WaitCreateMyUnit(zoneScene));           // 等待CreateMyUnit的消息
                await ETTaskHelper.WaitAll(tasks);
            }
            M2C_CreateMyUnit m2CCreateMyUnit = waitCreateMyUnit.Message;

            UnitFactory.Create(currentScene, m2CCreateMyUnit.Unit);
            // zoneScene.AddComponent<AIComponent,int>(1);

            await Game.EventSystem.PublishAsync(new EventType.SceneChangeFinish()
            {
                ZoneScene = zoneScene, CurrentScene = currentScene
            });

            // 通知等待场景切换的协程
            zoneScene.GetComponent <ObjectWait>().Notify(new WaitType.Wait_SceneChangeFinish());
        }
Ejemplo n.º 9
0
    void SpawnTestUnits()
    {
        string[] recipes = new string[]
        {
            "Otario",
            "Jones",
        };

        GameObject unitContainer = new GameObject("Units");

        unitContainer.transform.SetParent(owner.transform);

        List <HexCell> locations = Grid.GetCells();

        for (int i = 0; i < recipes.Length; ++i)
        {
            int        level    = UnityEngine.Random.Range(9, 12);
            GameObject instance = UnitFactory.Create(recipes[i], level);
            instance.transform.SetParent(unitContainer.transform);

            int     random     = UnityEngine.Random.Range(0, locations.Count);
            HexCell randomTile = locations[random];
            locations.RemoveAt(random);

            Unit unit = instance.GetComponent <Unit>();
            unit.Place(randomTile);
            unit.direction = (HexDirection)UnityEngine.Random.Range(0, 6);
            unit.Match();

            units.Add(unit);
        }
    }
Ejemplo n.º 10
0
        static void Main(string[] args)
        {
            IUnitFactory infantryFactory = new UnitFactory <Infantry>();
            IUnitFactory knightFactory   = new UnitFactory <Knight>();

            var          armies      = new IEnumerable <IUnit> [6];
            IArmyFactory armyFactory = new RandomArmyFactory(
                infantryFactory, knightFactory, knightFactory, infantryFactory, knightFactory
                );

            Console.WriteLine("---Random armies(max 1000 cost)");
            for (int i = 0; i < 4; i++)
            {
                armies[i] = armyFactory.Create(1000);
                Console.WriteLine(
                    string.Join(", ", armies[i]) +
                    $": OVERALL COSTS {armies[i].Sum(unit => unit.Cost)}"
                    );
            }

            armyFactory = new ConcreteArmyFactory(infantryFactory, knightFactory, infantryFactory);

            Console.WriteLine();
            Console.WriteLine("---Concrete army(max 600 cost)");

            armies[4] = armyFactory.Create(600);
            Console.WriteLine(
                string.Join(", ", armies[4]) +
                $": OVERALL COSTS {armies[4].Sum(unit => unit.Cost)}"
                );

            armyFactory = new UnitsCloningFactory(
                infantryFactory.Create(),
                knightFactory.Create(),
                infantryFactory.Create()
                );

            Console.WriteLine();
            Console.WriteLine("--Units cloner(max 300 cost)");
            armies[5] = armyFactory.Create(300);
            Console.WriteLine(
                string.Join(", ", armies[5]) +
                $": OVERALL COSTS {armies[5].Sum(unit => unit.Cost)}"
                );
        }
Ejemplo n.º 11
0
 private IEnumerator SpawnWave(int AmountOfEnemies)
 {
     for (int i = 0; i < AmountOfEnemies; i++)
     {
         GameObject newEnemy = UnitFactory.Create("mech");
         newEnemy.GetComponent <Unit>().IsSpawned = true;
         CurrentWave.Add(newEnemy);
         yield return(new WaitForSeconds(WaveSpawnTimer + 1));
     }
 }
Ejemplo n.º 12
0
        public override void Execute(string[] commandArgs)
        {
            var unitType = (UnitType)Enum.Parse(typeof(UnitType), commandArgs[1]);
            var unitName = commandArgs[2];
            var x        = int.Parse(commandArgs[3]);
            var y        = int.Parse(commandArgs[4]);

            var unit = UnitFactory.Create(unitType, unitName, x, y);

            this.Engine.InsertUnit(unit);
            this.Engine.UnitContainer.Add(unit);
            this.Engine.OutputWriter.Write(string.Format(GlobalMessages.UnitSpawned, unitName));
        }
Ejemplo n.º 13
0
        protected override void Run(Session session, M2C_CreateUnits message)
        {
            Scene         currentScene  = session.DomainScene().CurrentScene();
            UnitComponent unitComponent = currentScene.GetComponent <UnitComponent>();

            foreach (UnitInfo unitInfo in message.Units)
            {
                if (unitComponent.Get(unitInfo.UnitId) != null)
                {
                    continue;
                }
                Unit unit = UnitFactory.Create(currentScene, unitInfo);
            }
        }
Ejemplo n.º 14
0
    void SpawnTestUnits()
    {
        string[] enemies = new string[]
        {
            "TestDummyGod",
            "TestDummyWeak",
            "TestDummyEqual"
        };
        List <Tile> locations = new List <Tile>(board.tiles.Values);

        for (int i = 0; i < locations.Count; ++i)
        {
            if (locations[i].pos.x != 5 || locations[i] == null)
            {
                locations.Remove(locations[i]);
                if (i >= 0)
                {
                    i--;
                }
            }
        }
        for (int i = 0; i < enemies.Length; ++i)
        {
            GameObject instance = UnitFactory.Create(enemies[i]);
            instance.transform.SetParent(owner.transform.Find("NPCs"));
            int  random     = UnityEngine.Random.Range(0, locations.Count);
            Tile randomTile = locations[random];
            locations.RemoveAt(random);
            Unit unit = instance.GetComponent <Unit>();
            unit.Place(randomTile);
            unit.dir = Directions.North;
            unit.Match();
            enemyUnits.Add(unit);
        }
        GameObject heroInstance = UnitFactory.Create("Hero");

        heroInstance.transform.SetParent(owner.transform.Find("Player"));
        Unit heroUnit = heroInstance.GetComponent <Unit>();

        heroUnit.Place(board.GetTile(new Point(0, 1)));
        heroUnit.Match();
        heroUnit.transform.rotation        = Quaternion.Euler(0, 180, 0);
        heroUnit.GetComponent <Mana>().MMP = 1000;
        heroUnit.GetComponent <Mana>().MP  = 1000;
        owner.playerUnit = heroUnit;
        SelectTile(heroUnit.tile.pos);
        heroUnit.GetComponent <Health>().HP -= 50;
        Debug.Log("Player Mana for testing: " + owner.playerUnit.GetComponent <Mana>().MP);
    }
Ejemplo n.º 15
0
        protected override async ETTask Run(Session session, M2C_CreateUnits message)
        {
            UnitComponent unitComponent = session.Domain.GetComponent <UnitComponent>();

            foreach (UnitInfo unitInfo in message.Units)
            {
                if (unitComponent.Get(unitInfo.UnitId) != null)
                {
                    continue;
                }
                Unit unit = UnitFactory.Create(session.Domain, unitInfo);
            }

            await ETTask.CompletedTask;
        }
Ejemplo n.º 16
0
        protected override async ETTask Run(DCET.Model.Session session, M2C_CreateUnits message)
        {
            UnitComponent unitComponent = DCET.Model.Game.Scene.GetComponent <UnitComponent>();

            foreach (UnitInfo unitInfo in message.Units)
            {
                if (unitComponent.Get(unitInfo.UnitId) != null)
                {
                    continue;
                }
                Unit unit = UnitFactory.Create(DCET.Model.Game.Scene, unitInfo.UnitId);
                unit.Position = new Vector3(unitInfo.X, unitInfo.Y, unitInfo.Z);
            }

            await ETTask.CompletedTask;
        }
Ejemplo n.º 17
0
        public void It_should_create_correct_unit_with_appropriate_parameters(UnitType unitType, int expectedHitPoints,
                                                                              int expectedAttack)
        {
            // Given
            UnitFactory unitFactory = new UnitFactory();

            // When
            IUnit unit = unitFactory.Create(unitType);

            // Then
            Assert.Multiple(() =>
            {
                Assert.NotNull(unit);
                Assert.AreEqual(expectedHitPoints, unit.HitPoints);
                Assert.AreEqual(expectedAttack, unit.Attack);
            });
        }
Ejemplo n.º 18
0
        public bool LoadGame()
        {
            if (PlayerPrefs.HasKey(GameSave) == false)
            {
                return(false);
            }

            var units = _pool.Provide <UnitComponent>().Items;

            while (units.Count > 0)
            {
                _context.entities.Destroy(units[0].Id);
            }

            var info = (SaveInfo)JsonUtility.FromJson(PlayerPrefs.GetString(GameSave), typeof(SaveInfo));

            _pool.Provide <BoardStateComponent>()
            .Single().Type = info.State.Type;

            var gameTime = _pool.Provide <GameTimeComponent>().Single();

            gameTime.gameTime         = info.GameTime.gameTime;
            gameTime.unscaledGameTime = info.GameTime.unscaledGameTime;

            var positionDict = info.Positions.ToDictionary(p => p.Id);
            var radiusDict   = info.Radiuses.ToDictionary(p => p.Id);
            var moveDict     = info.Moves.ToDictionary(p => p.Id);

            for (int i = 0; i < info.Units.Length; i++)
            {
                var unit = info.Units[i];

                var pos    = positionDict[unit.Id].Position;
                var radius = radiusDict[unit.Id].Radius;

                MoveComponent move;

                moveDict.TryGetValue(unit.Id, out move);

                _unitFactory.Create(unit.type, pos, radius, move);
            }

            return(true);
        }
Ejemplo n.º 19
0
        void FixedUpdate()
        {
            _current -= Time.fixedDeltaTime;

            if (_current <= 0f)
            {
                var unit       = _unitFactory.Create(Type, _controller.PlayerOwner, _x, _y);
                var pathfinder = unit.GetComponent <PathFinderFollower>();

                try
                {
                    pathfinder.MoveTo(_playerManager.HumanPlayer.StartSpawnX, _playerManager.HumanPlayer.StartSpawnY, true);
                    //pathfinder.MoveTo(0, 0, true);
                }
                catch { /* ignore */ }

                _current = Cooldown;
            }
        }
Ejemplo n.º 20
0
        public void CreateGuilds()
        {
            void SetPosition(UnitSide unitSide)
            {
                var unit = _unitFactory.Create(unitSide);

                unit.Position = _guildPositionController.GetRandomPosition(unitSide);
                unit.Rotation = _guildPositionController.GetRotation(unitSide);
                AddUnit(unit);
            }

            for (var i = 0; i < _gameSettings.GuildSizeA; i++)
            {
                SetPosition(UnitSide.SideA);
            }

            for (var i = 0; i < _gameSettings.GuildSizeB; i++)
            {
                SetPosition(UnitSide.SideB);
            }
        }
Ejemplo n.º 21
0
        internal void OnClickMapCell(CellComponent cellComponent, float xPercent, float yPercent)
        {
            if (model.GetSelectionState().SelectionType == typeof(ZRTSModel.Tile))
            {
                TileFactory           tf      = TileFactory.Instance;
                ZRTSModel.Tile        tile    = tf.GetImprovedTile(model.GetSelectionState().SelectedTileType);
                ChangeCellTileCommand command = new ChangeCellTileCommand(cellComponent, tile);

                if (command.CanBeDone())
                {
                    model.GetCommandStack().ExecuteCommand(command);
                }
            }
            else if (model.GetSelectionState().SelectionType == typeof(UnitComponent))
            {
                UnitFactory   uf   = UnitFactory.Instance;
                UnitComponent unit = uf.Create(model.GetSelectionState().SelectedUnitType);
                //unit.PointLocation = new PointF((float)cellComponent.X + xPercent, (float)cellComponent.Y + yPercent);
                PlayerComponent player  = model.GetScenario().GetGameWorld().GetPlayerList().GetPlayerByName(model.GetSelectionState().SelectedPlayer);
                AddUnitCommand  command = new AddUnitCommand(unit, player, cellComponent);

                if (command.CanBeDone())
                {
                    model.GetCommandStack().ExecuteCommand(command);
                }
            }
            else if (model.GetSelectionState().SelectionType == typeof(Building))
            {
                BuildingFactory bf       = BuildingFactory.Instance;
                Building        building = bf.Build(model.GetSelectionState().SelectedBuildingType, true);
                //building.PointLocation = new PointF((float)cellComponent.X + xPercent, (float)cellComponent.Y + yPercent);
                PlayerComponent    player  = model.GetScenario().GetGameWorld().GetPlayerList().GetPlayerByName(model.GetSelectionState().SelectedPlayer);
                AddBuildingCommand command = new AddBuildingCommand(building, player, cellComponent);

                if (command.CanBeDone())
                {
                    model.GetCommandStack().ExecuteCommand(command);
                }
            }
        }
Ejemplo n.º 22
0
    void SpawnTestUnits()
    {
        string[] recipes = new string[]
        {
            "오딘",
            "소냐",
            "캐롤",
            "도적 암살자",
            "도적 전사",
            "도적 마법사"
        };

        GameObject unitContainer = new GameObject("Units");

        unitContainer.transform.SetParent(owner.transform);

        List <Tile> locations = new List <Tile>(board.tiles.Values);

        for (int i = 0; i < recipes.Length; ++i)
        {
            int        level    = Random.Range(9, 12);
            GameObject instance = UnitFactory.Create(recipes[i], level);
            instance.transform.SetParent(unitContainer.transform);

            int  random     = Random.Range(0, locations.Count);
            Tile randomTile = locations[random];
            locations.RemoveAt(random);

            Unit unit = instance.GetComponent <Unit>();
            unit.Place(randomTile);
            unit.dir = (Directions)Random.Range(0, 4);
            unit.Match();

            units.Add(unit);
        }

        SelectTile(units[0].tile.pos);
    }
Ejemplo n.º 23
0
 private void SpawnUnit()
 {
     UnitFactory.Create("mech");
 }
Ejemplo n.º 24
0
 public void Initialize()
 {
     factory.Create(UnitType.Worker, 0, 5, 5);
 }
Ejemplo n.º 25
0
    void SpawnUnits()
    {
        if (SceneManager.GetActiveScene().name == "Battle")
        {
            string[] recipes = new string[]
            {
                "Alaois",
                "Hania",
                "Kamau",
                "Alphonse",
                "Roderick",
                "Enemy Scout",
                "Enemy Scout",
                "Enemy Warrior",
                "Enemy Warrior",
                "Enemy Mage"
            };

            GameObject unitContainer = new GameObject("Units");
            unitContainer.transform.SetParent(owner.transform);

            List <Tile> locations = new List <Tile>(board.tiles.Values);
            for (int i = 0; i < recipes.Length; ++i)
            {
                int        level    = 10;
                GameObject instance = UnitFactory.Create(recipes[i], level);
                instance.transform.SetParent(unitContainer.transform);

                for (int j = 0; j < locations.Count; j++)
                {
                    Tile tile = locations[j];
                    switch (i)
                    {
                    case 0:
                        if (tile.pos == new Point(7, 1))
                        {
                            //locations.RemoveAt(j);
                            Unit unit = instance.GetComponent <Unit>();
                            unit.Place(tile);
                            unit.dir = (Directions)0;
                            unit.Match();
                            units.Add(unit);
                        }
                        else
                        {
                            break;
                        }
                        break;

                    case 1:
                        if (tile.pos == new Point(8, 1))
                        {
                            //locations.RemoveAt(j);
                            Unit unit = instance.GetComponent <Unit>();
                            unit.Place(tile);
                            unit.dir = (Directions)0;
                            unit.Match();
                            units.Add(unit);
                        }
                        else
                        {
                            break;
                        }
                        break;

                    case 2:
                        if (tile.pos == new Point(9, 1))
                        {
                            //locations.RemoveAt(j);
                            Unit unit = instance.GetComponent <Unit>();
                            unit.Place(tile);
                            unit.dir = (Directions)0;
                            unit.Match();
                            units.Add(unit);
                        }
                        else
                        {
                            break;
                        }
                        break;

                    case 3:
                        if (tile.pos == new Point(6, 1))
                        {
                            //locations.RemoveAt(j);
                            Unit unit = instance.GetComponent <Unit>();
                            unit.Place(tile);
                            unit.dir = (Directions)0;
                            unit.Match();
                            units.Add(unit);
                        }
                        else
                        {
                            break;
                        }
                        break;

                    case 4:
                        if (tile.pos == new Point(10, 1))
                        {
                            //locations.RemoveAt(j);
                            Unit unit = instance.GetComponent <Unit>();
                            unit.Place(tile);
                            unit.dir = (Directions)0;
                            unit.Match();
                            units.Add(unit);
                        }
                        else
                        {
                            break;
                        }
                        break;

                    case 5:
                        if (tile.pos == new Point(1, 11))
                        {
                            //locations.RemoveAt(j);
                            Unit unit = instance.GetComponent <Unit>();
                            unit.Place(tile);
                            unit.dir = (Directions)2;
                            unit.Match();
                            units.Add(unit);
                        }
                        else
                        {
                            break;
                        }
                        break;

                    case 6:
                        if (tile.pos == new Point(2, 11))
                        {
                            //locations.RemoveAt(j);
                            Unit unit = instance.GetComponent <Unit>();
                            unit.Place(tile);
                            unit.dir = (Directions)2;
                            unit.Match();
                            units.Add(unit);
                        }
                        else
                        {
                            break;
                        }
                        break;

                    case 7:
                        if (tile.pos == new Point(3, 11))
                        {
                            //locations.RemoveAt(j);
                            Unit unit = instance.GetComponent <Unit>();
                            unit.Place(tile);
                            unit.dir = (Directions)2;
                            unit.Match();
                            units.Add(unit);
                        }
                        else
                        {
                            break;
                        }
                        break;

                    case 8:
                        if (tile.pos == new Point(4, 11))
                        {
                            //locations.RemoveAt(j);
                            Unit unit = instance.GetComponent <Unit>();
                            unit.Place(tile);
                            unit.dir = (Directions)2;
                            unit.Match();
                            units.Add(unit);
                        }
                        else
                        {
                            break;
                        }
                        break;

                    case 9:
                        if (tile.pos == new Point(5, 11))
                        {
                            //locations.RemoveAt(j);
                            Unit unit = instance.GetComponent <Unit>();
                            unit.Place(tile);
                            unit.dir = (Directions)2;
                            unit.Match();
                            units.Add(unit);
                        }
                        else
                        {
                            break;
                        }
                        break;

                    default:
                        break;
                    }
                }
            }
            SelectTile(units[0].tile.pos);
        }
        else if (SceneManager.GetActiveScene().name == "Test")
        {
            string[] recipes = new string[]
            {
                "Alaois",
                "Enemy Mage"
            };

            GameObject unitContainer = new GameObject("Units");
            unitContainer.transform.SetParent(owner.transform);

            List <Tile> locations = new List <Tile>(board.tiles.Values);
            for (int i = 0; i < recipes.Length; ++i)
            {
                int        level    = 10;
                GameObject instance = UnitFactory.Create(recipes[i], level);
                instance.transform.SetParent(unitContainer.transform);

                for (int j = 0; j < locations.Count; j++)
                {
                    Tile tile = locations[j];
                    switch (i)
                    {
                    case 0:
                        if (tile.pos == new Point(7, 1))
                        {
                            //locations.RemoveAt(j);
                            Unit unit = instance.GetComponent <Unit>();
                            unit.Place(tile);
                            unit.dir = (Directions)0;
                            unit.Match();
                            units.Add(unit);
                        }
                        else
                        {
                            break;
                        }
                        break;

                    case 1:
                        if (tile.pos == new Point(8, 1))
                        {
                            //locations.RemoveAt(j);
                            Unit unit = instance.GetComponent <Unit>();
                            unit.Place(tile);
                            unit.dir = (Directions)0;
                            unit.Match();
                            units.Add(unit);
                        }
                        else
                        {
                            break;
                        }
                        break;

                    default:
                        break;
                    }
                }
            }
            SelectTile(units[0].tile.pos);
        }
        else if (SceneManager.GetActiveScene().name == "BattleFront")
        {
            string[] recipes = new string[]
            {
                "Alaois",
                "Kamau",
                "Hania",
                "Alphonse",
                "Roderick",
                "Enemy Mage",
                "Enemy Mage",
                "Enemy Scout",
                "Enemy Scout",
                "Enemy Warrior",
                "Enemy Warrior",
                "Enemy Warrior",
                "Enemy Warrior",
                "Enemy Warrior",
                "Enemy Warrior"
            };

            GameObject unitContainer = new GameObject("Units");
            unitContainer.transform.SetParent(owner.transform);

            List <Tile> locations = new List <Tile>(board.tiles.Values);
            for (int i = 0; i < recipes.Length; ++i)
            {
                int        level    = 10;
                GameObject instance = UnitFactory.Create(recipes[i], level);
                instance.transform.SetParent(unitContainer.transform);

                for (int j = 0; j < locations.Count; j++)
                {
                    Tile tile = locations[j];
                    switch (i)
                    {
                    case 0:
                        if (tile.pos == new Point(5, 3))
                        {
                            //locations.RemoveAt(j);
                            Unit unit = instance.GetComponent <Unit>();
                            unit.Place(tile);
                            unit.dir = (Directions)1;
                            unit.Match();
                            units.Add(unit);
                        }
                        else
                        {
                            break;
                        }
                        break;

                    case 1:
                        if (tile.pos == new Point(5, 4))
                        {
                            //locations.RemoveAt(j);
                            Unit unit = instance.GetComponent <Unit>();
                            unit.Place(tile);
                            unit.dir = (Directions)1;
                            unit.Match();
                            units.Add(unit);
                        }
                        else
                        {
                            break;
                        }
                        break;

                    case 2:
                        if (tile.pos == new Point(5, 5))
                        {
                            //locations.RemoveAt(j);
                            Unit unit = instance.GetComponent <Unit>();
                            unit.Place(tile);
                            unit.dir = (Directions)1;
                            unit.Match();
                            units.Add(unit);
                        }
                        else
                        {
                            break;
                        }
                        break;

                    case 3:
                        if (tile.pos == new Point(5, 6))
                        {
                            //locations.RemoveAt(j);
                            Unit unit = instance.GetComponent <Unit>();
                            unit.Place(tile);
                            unit.dir = (Directions)1;
                            unit.Match();
                            units.Add(unit);
                        }
                        else
                        {
                            break;
                        }
                        break;

                    case 4:
                        if (tile.pos == new Point(5, 7))
                        {
                            //locations.RemoveAt(j);
                            Unit unit = instance.GetComponent <Unit>();
                            unit.Place(tile);
                            unit.dir = (Directions)1;
                            unit.Match();
                            units.Add(unit);
                        }
                        else
                        {
                            break;
                        }
                        break;

                    //UNIDADES ENEMIGAS

                    case 5:
                        if (tile.pos == new Point(13, 3))
                        {
                            //locations.RemoveAt(j);
                            Unit unit = instance.GetComponent <Unit>();
                            unit.Place(tile);
                            unit.dir = (Directions)3;
                            unit.Match();
                            units.Add(unit);
                        }
                        else
                        {
                            break;
                        }
                        break;

                    case 6:
                        if (tile.pos == new Point(13, 4))
                        {
                            //locations.RemoveAt(j);
                            Unit unit = instance.GetComponent <Unit>();
                            unit.Place(tile);
                            unit.dir = (Directions)3;
                            unit.Match();
                            units.Add(unit);
                        }
                        else
                        {
                            break;
                        }
                        break;

                    case 7:
                        if (tile.pos == new Point(13, 6))
                        {
                            //locations.RemoveAt(j);
                            Unit unit = instance.GetComponent <Unit>();
                            unit.Place(tile);
                            unit.dir = (Directions)3;
                            unit.Match();
                            units.Add(unit);
                        }
                        else
                        {
                            break;
                        }
                        break;

                    case 8:
                        if (tile.pos == new Point(13, 7))
                        {
                            //locations.RemoveAt(j);
                            Unit unit = instance.GetComponent <Unit>();
                            unit.Place(tile);
                            unit.dir = (Directions)3;
                            unit.Match();
                            units.Add(unit);
                        }
                        else
                        {
                            break;
                        }
                        break;

                    case 9:
                        if (tile.pos == new Point(12, 3))
                        {
                            //locations.RemoveAt(j);
                            Unit unit = instance.GetComponent <Unit>();
                            unit.Place(tile);
                            unit.dir = (Directions)3;
                            unit.Match();
                            units.Add(unit);
                        }
                        else
                        {
                            break;
                        }
                        break;

                    case 10:
                        if (tile.pos == new Point(12, 4))
                        {
                            //locations.RemoveAt(j);
                            Unit unit = instance.GetComponent <Unit>();
                            unit.Place(tile);
                            unit.dir = (Directions)3;
                            unit.Match();
                            units.Add(unit);
                        }
                        else
                        {
                            break;
                        }
                        break;

                    case 11:
                        if (tile.pos == new Point(12, 5))
                        {
                            //locations.RemoveAt(j);
                            Unit unit = instance.GetComponent <Unit>();
                            unit.Place(tile);
                            unit.dir = (Directions)3;
                            unit.Match();
                            units.Add(unit);
                        }
                        else
                        {
                            break;
                        }
                        break;

                    case 12:
                        if (tile.pos == new Point(12, 6))
                        {
                            //locations.RemoveAt(j);
                            Unit unit = instance.GetComponent <Unit>();
                            unit.Place(tile);
                            unit.dir = (Directions)3;
                            unit.Match();
                            units.Add(unit);
                        }
                        else
                        {
                            break;
                        }
                        break;

                    case 13:
                        if (tile.pos == new Point(12, 7))
                        {
                            //locations.RemoveAt(j);
                            Unit unit = instance.GetComponent <Unit>();
                            unit.Place(tile);
                            unit.dir = (Directions)3;
                            unit.Match();
                            units.Add(unit);
                        }
                        else
                        {
                            break;
                        }
                        break;

                    case 14:
                        if (tile.pos == new Point(11, 5))
                        {
                            //locations.RemoveAt(j);
                            Unit unit = instance.GetComponent <Unit>();
                            unit.Place(tile);
                            unit.dir = (Directions)3;
                            unit.Match();
                            units.Add(unit);
                        }
                        else
                        {
                            break;
                        }
                        break;

                    default:
                        break;
                    }
                }
            }
            SelectTile(units[0].tile.pos);
        }
    }