private Vector3 CreateTankIcon()
    {
        if (_tankIconRoot == null)
        {
            _tankIconRoot = new GameObject("TankIconRoot");
        }

        _tankIconRoot.transform.position = new Vector3();
        Vector3 tileCenter = GetTileCenter(_selectTileIndex);

        float minX = int.MaxValue;
        float minY = int.MaxValue;
        float maxX = int.MinValue;
        float maxY = int.MinValue;

        DataMission    mission = _dataCampaign.missions [_selectTileIndex];
        InstanceBattle battle  = new InstanceBattle();

        battle.ImportFromLevel(mission);
        InstanceTeam team = battle.enemyTeams [0];

        for (int i = 0; i < team.units.Length; ++i)
        {
            int unitId = team.units [i].unitId;
            if (unitId > 0)
            {
                DataUnit unit = DataManager.instance.dataUnitsGroup.GetUnit(unitId);

//				GameObject tank = ResourceHelper.Load (AppConfig.FOLDER_PROFAB_TANK + "tankIconPrimitive");
//				tank.transform.parent = _tankIconRoot.transform;

                Vector3 pos = tileCenter;
                pos.x += ((i % 3) - 1) * 27 * TANK_SIZE_SCALE;
                pos.y += ((i / 3) - 1) * 18 * TANK_SIZE_SCALE;
                pos.z  = -1;
//				tank.GetComponent<CampaignUnitIcon> ().Init (pos, unit, -60, -60);

                GameObject tank = TankIconSpineAttach.Create(unit, pos, TANK_SIZE_SCALE, -60, -60);
                tank.transform.parent = _tankIconRoot.transform;

                _tankIcons [i] = tank;

                minX = Math.Min(minX, pos.x);
                minY = Math.Min(minY, pos.y);
                maxX = Math.Max(maxX, pos.x);
                maxY = Math.Max(maxY, pos.y);
            }
        }

        Vector3 translate = FixIconPosition(minX, minY, maxX, maxY);

        return(translate);
    }
Beispiel #2
0
    public static GameObject[][] CreateBattleUnits(InstanceBattle battle, DataMap dataMap)
    {
        int totalGroup = 1 + battle.extraTeamCount;

        GameObject[][] objects = new GameObject[totalGroup][];

        GameObject[] myObjects = CreateBattleTeam(battle.myTeam, DataConfig.TEAM.MY, dataMap.startPosition, dataMap.startPosition, battle.mission.playerRotation);
        objects [0] = myObjects;

        for (int i = 1; i < totalGroup; ++i)
        {
            int   teamIndex = i - 1;
            COORD location  = dataMap.GetExtraPosition(teamIndex);

            InstanceTeam enemyTeam  = battle.enemyTeams[teamIndex];
            InstanceTeam friendTeam = battle.friendTeams[teamIndex];
            Assert.assert(enemyTeam == null || friendTeam == null);

            float teamRotation = battle.mission.teamsRotation[teamIndex];

            GameObject[] members = null;
            if (enemyTeam != null)
            {
                Assert.assert(location != null);
                members = CreateBattleTeam(enemyTeam, DataConfig.TEAM.ENEMY, location, dataMap.startPosition, teamRotation);
            }
            if (friendTeam != null)
            {
                Assert.assert(location != null);
                members = CreateBattleTeam(friendTeam, DataConfig.TEAM.FRIEND, location, dataMap.startPosition, teamRotation);
            }
            objects [i] = members;
        }

        return(objects);
    }