예제 #1
0
    public void FillTile(Index index)
    {
        if (AlreadySpawned(index))
        {
            return;
        }

        tempBuildingInstance = instanceManager.GetBuilding(index);
        if (tempBuildingInstance != null)
        {
            MapUtils.GetIndexDistanceToAreaMidPoint(index, tempBuildingInstance.index, tempBuildingInstance.lastIndex, out offsetVec);

            tempPoolObje = poolController.GetPoolObje(buildingObjeType.value, GetTileByIndex(index.x, index.y).transform.position + (Vector3)offsetVec);
            tempBuilding = tempPoolObje.GetComponent <Building>();
            tempBuilding.Set(tempBuildingInstance);
            activeBuildings.Add(tempBuilding);
            return;
        }

        tempSoldierInstances = instanceManager.GetSoldier(index);
        if (tempSoldierInstances != null)
        {
            for (int i = 0; i < tempSoldierInstances.Count; i++)
            {
                tempPoolObje = poolController.GetPoolObje(soldierObjeType.value, GetTileByIndex(index.x, index.y).transform.position);
                tempSoldier  = tempPoolObje.GetComponent <Soldier>();
                tempSoldier.Set(tempSoldierInstances[i]);
                activeSoldiers.Add(tempSoldier);
                E_SoldierActivated.Invoke(tempSoldier);
            }
        }
    }
예제 #2
0
    public void ActivateSoldier(Instance_Soldier soldierInstance)
    {
        for (int i = 0; i < activeSoldiers.Count; i++)
        {
            if (activeSoldiers[i].soldierInstance == soldierInstance)
            {
                return;
            }
        }

        if (!MapUtils.PositionInArea(soldierInstance.position, tiles[0][0].index, tiles[height.value - 1][width.value - 1].index))
        {
            return;
        }

        tempPoolObje = poolController.GetPoolObje(soldierObjeType.value);
        tempSoldier  = tempPoolObje.GetComponent <Soldier>();
        activeSoldiers.Add(tempSoldier);
        tempSoldier.Set(soldierInstance);
        E_SoldierActivated.Invoke(tempSoldier);
    }