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);
    }
Esempio n. 2
0
    public void ImportFromPvp(SlgPB.PVPUser pvpUser)
    {
        InitPvpDataMap(pvpUser);

        mission       = new DataMission();
        mission.asset = DataMission.BK_NAMES [(int)RandomHelper.Range(0, DataMission.BK_NAMES.Length)];

        extraTeamCount = 1;
        enemyTeams     = new InstanceTeam[extraTeamCount];
        friendTeams    = new InstanceTeam[extraTeamCount];

        InstanceTeam instanceTeam = new InstanceTeam();

        instanceTeam.units = new InstanceUnitPvp[DataConfig.FORMATION_TOTAL_SLOT];

        int memberCount = pvpUser.unitGroups.Count;

        for (int i = 0; i < memberCount; ++i)
        {
            SlgPB.UnitGroup group = pvpUser.unitGroups [i];

            int   unitId     = group.unitId;
            int   unitCount  = group.num;
            int   heroId     = group.heroId;
            float powerScale = 1;

            if (unitId > 0 && unitCount > 0)
            {
                SlgPB.Hero pbHero = null;
                if (pbHeroesMap.ContainsKey(heroId))
                {
                    pbHero = pbHeroesMap [heroId];
                }

                SlgPB.Unit pbUnit = null;
                if (pbUnitsMap.ContainsKey(unitId))
                {
                    pbUnit = pbUnitsMap [unitId];
                }

                InstanceUnitPvp instanceUnitPvp = new InstanceUnitPvp(false, heroId, unitId, unitCount, powerScale, pbHero, pbUnit);
                instanceUnitPvp.Init();

                int slotId = group.posId - 1;
                instanceTeam.units[slotId] = instanceUnitPvp;
            }
        }

        enemyTeams [0] = instanceTeam;
    }
Esempio n. 3
0
    public void ImportFromLevel(DataMission mission)
    {
        this.mission = mission;

        extraTeamCount = mission.teamsId.Length;
        enemyTeams     = new InstanceTeam[extraTeamCount];
        friendTeams    = new InstanceTeam[extraTeamCount];

        for (int teamIndex = 0; teamIndex < extraTeamCount; ++teamIndex)
        {
            int teamId = mission.teamsId[teamIndex];
            if (teamId != 0)
            {
                int   memberCount = mission.GetMemberCount(teamIndex);
                int[] unitsId     = mission.GetUnitsId(teamIndex);
                int[] unitsCount  = mission.GetUnitsCount(teamIndex);

                InstanceTeam instanceTeam = new InstanceTeam();

                for (int i = 0; i < memberCount; ++i)
                {
                    int   unitId     = unitsId[i];
                    int   unitCount  = unitsCount[i];
                    int   heroId     = 0;
                    float powerScale = mission.powerScale;

                    if (unitId > 0 && unitCount > 0)
                    {
                        InstanceUnit instanceUnit = new InstanceUnit(false, heroId, unitId, unitCount, powerScale);
                        instanceTeam.units[i] = instanceUnit;
                        instanceUnit.Init();
                    }
                }

                if (teamId > 0)
                {
                    enemyTeams[teamIndex] = instanceTeam;
                }
                else
                {
                    friendTeams[teamIndex] = instanceTeam;
                }
            }
        }
    }
Esempio n. 4
0
    public static GameObject[] CreateBattleTeam(InstanceTeam team, DataConfig.TEAM teamSide,
                                                COORD location, COORD playerLocation, float rotationDegree)
    {
        int n = team.units.Length;

        GameObject[] objects = new GameObject[n];

        for (int i = 0; i < n; ++i)
        {
            InstanceUnit unit = team.units[i];
            if (unit != null)
            {
                GameObject obj = CreateBattleUnit(unit, i, teamSide, location, playerLocation, rotationDegree);
                objects[i] = obj;
            }
        }

        return(objects);
    }
Esempio n. 5
0
    public void ImportFromPlayer()
    {
        InstancePlayerArmy playerArmy = InstancePlayer.instance.playerArmy;

        InstanceTeam instanceTeam = new InstanceTeam();

        for (int i = 0; i < playerArmy.memberCount; ++i)
        {
            int   unitId     = playerArmy.unitId[i];
            int   unitCount  = playerArmy.unitCount[i];
            int   heroId     = playerArmy.heroId [i];
            float powerScale = 1;

            if (unitId > 0 && unitCount > 0)
            {
                InstanceUnit instanceUnit = new InstanceUnit(true, heroId, unitId, unitCount, powerScale);
                instanceTeam.units[i] = instanceUnit;
                instanceUnit.Init();
            }
        }

        myTeam = instanceTeam;
    }
Esempio n. 6
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);
    }