Beispiel #1
0
    // Token: 0x060022A9 RID: 8873 RVA: 0x004091D8 File Offset: 0x004073D8
    private void setupSoldierArray(EGroupKind groupKind)
    {
        Vector3 zero = Vector3.zero;

        if (groupKind == EGroupKind.Cavalry)
        {
            float num = 1f;
            zero.Set(-num, 0f, num);
            this.soldierArray[0] = zero;
            zero.Set(num, 0f, num);
            this.soldierArray[1] = zero;
            zero.Set(-num * 3f, 0f, -num);
            this.soldierArray[2] = zero;
            zero.Set(num * 3f, 0f, -num);
            this.soldierArray[3] = zero;
            zero.Set(-num * 3f, 0f, -num * 3.5f);
            this.soldierArray[4] = zero;
            zero.Set(num * 3f, 0f, -num * 3.5f);
            this.soldierArray[5] = zero;
        }
        else if (groupKind == EGroupKind.Catapults)
        {
            zero.Set(0f, 0f, 0f);
            this.soldierArray[0] = zero;
        }
        else if (groupKind == EGroupKind.Archer)
        {
            ArmyGroup.RandomPosList.Clear();
            for (byte b = 0; b < 9; b += 1)
            {
                ArmyGroup.RandomPosList.Add(b);
            }
            float num2 = 1.5f;
            zero.Set(0f, 0f, 0f);
            this.soldierArray[(int)this.getRandowPos()] = zero;
            zero.Set(-num2, 0f, -num2 * 1f);
            this.soldierArray[(int)this.getRandowPos()] = zero;
            zero.Set(0f, 0f, -num2 * 1f);
            this.soldierArray[(int)this.getRandowPos()] = zero;
            zero.Set(num2, 0f, -num2 * 1f);
            this.soldierArray[(int)this.getRandowPos()] = zero;
            zero.Set(-num2, 0f, -num2 * 2f);
            this.soldierArray[(int)this.getRandowPos()] = zero;
            zero.Set(0f, 0f, -num2 * 2f);
            this.soldierArray[(int)this.getRandowPos()] = zero;
            zero.Set(num2, 0f, -num2 * 2f);
            this.soldierArray[(int)this.getRandowPos()] = zero;
            zero.Set(-num2, 0f, -num2 * 3f);
            this.soldierArray[(int)this.getRandowPos()] = zero;
            zero.Set(num2, 0f, -num2 * 3f);
            this.soldierArray[(int)this.getRandowPos()] = zero;
        }
        else
        {
            ArmyGroup.RandomPosList.Clear();
            for (byte b2 = 0; b2 < 12; b2 += 1)
            {
                ArmyGroup.RandomPosList.Add(b2);
            }
            float num3 = 1.5f;
            float num4 = 1.8f;
            zero.Set(0f, 0f, num3);
            this.soldierArray[(int)this.getRandowPos()] = zero;
            zero.Set(-num3, 0f, 0f);
            this.soldierArray[(int)this.getRandowPos()] = zero;
            zero.Set(0f, 0f, 0f);
            this.soldierArray[(int)this.getRandowPos()] = zero;
            zero.Set(num3, 0f, 0f);
            this.soldierArray[(int)this.getRandowPos()] = zero;
            zero.Set(-num3, 0f, -num4 * 1f);
            this.soldierArray[(int)this.getRandowPos()] = zero;
            zero.Set(0f, 0f, -num4 * 1f);
            this.soldierArray[(int)this.getRandowPos()] = zero;
            zero.Set(num3, 0f, -num4 * 1f);
            this.soldierArray[(int)this.getRandowPos()] = zero;
            zero.Set(-num3, 0f, -num4 * 2f);
            this.soldierArray[(int)this.getRandowPos()] = zero;
            zero.Set(0f, 0f, -num4 * 2f);
            this.soldierArray[(int)this.getRandowPos()] = zero;
            zero.Set(num3, 0f, -num4 * 2f);
            this.soldierArray[(int)this.getRandowPos()] = zero;
            zero.Set(-num3, 0f, -num4 * 3f);
            this.soldierArray[(int)this.getRandowPos()] = zero;
            zero.Set(num3, 0f, -num4 * 3f);
            this.soldierArray[(int)this.getRandowPos()] = zero;
        }
    }
Beispiel #2
0
    // Token: 0x0600229A RID: 8858 RVA: 0x004089B0 File Offset: 0x00406BB0
    public ArmyGroup(EGroupKind groupKind, byte tier, Transform renderRoot, byte side, byte texColor, ushort heroID, byte index, bool hasLord, float scaleFactor = 1f)
    {
        if (ArmyGroup.m_FSMMap == null)
        {
            ArmyGroup.m_FSMMap = new Dictionary <ArmyGroup.EGROUPSTATE, EStateName>();
            ArmyGroup.m_FSMMap.Add(ArmyGroup.EGROUPSTATE.MOVING, EStateName.MOVING);
            ArmyGroup.m_FSMMap.Add(ArmyGroup.EGROUPSTATE.RETREAT_MOVING_SPREAD, EStateName.MOVING);
            ArmyGroup.m_FSMMap.Add(ArmyGroup.EGROUPSTATE.RETREAT_MOVING, EStateName.MOVING);
            ArmyGroup.m_FSMMap.Add(ArmyGroup.EGROUPSTATE.FIGHT, EStateName.TRYFIGHT);
            ArmyGroup.m_FSMMap.Add(ArmyGroup.EGROUPSTATE.FIGHT_IMMEDIATE, EStateName.MELEE_FIGHT_IMMEDIATE);
            ArmyGroup.m_FSMMap.Add(ArmyGroup.EGROUPSTATE.IDLE_WITHOUT_CLUMP, EStateName.IDLE_WITHOUT_CLUMP);
            ArmyGroup.m_FSMMap.Add(ArmyGroup.EGROUPSTATE.VICTORY, EStateName.VICTORY);
            ArmyGroup.m_FSMMap.Add(ArmyGroup.EGROUPSTATE.MOVE_OUTOF_TOWN, EStateName.MOVE_OUTOF_TOWN);
            ArmyGroup.m_FSMMap.Add(ArmyGroup.EGROUPSTATE.JUMP_FROM_WALL, EStateName.JUMP_FROM_WALL);
            ArmyGroup.m_FSMMap.Add(ArmyGroup.EGROUPSTATE.GO_CAPTIVING, EStateName.GO_CAPTIVING);
            ArmyGroup.m_FSMMap.Add(ArmyGroup.EGROUPSTATE.ATTACKER_RUN_AWAY, EStateName.ATTACKER_RUN_AWAY);
            ArmyGroup.m_FSMMap.Add(ArmyGroup.EGROUPSTATE.DEFENSER_CHASING, EStateName.DEFENSER_CHASING);
            ArmyGroup.m_FSMMap.Add(ArmyGroup.EGROUPSTATE.DEFENSER_RUN_AWAY, EStateName.DEFENSER_RUN_AWAY);
            ArmyGroup.m_FSMMap.Add(ArmyGroup.EGROUPSTATE.ATTACKER_CHASING, EStateName.ATTACKER_CHASING);
            ArmyGroup.m_FSMMap.Add(ArmyGroup.EGROUPSTATE.IDLE, EStateName.IDLE);
        }
        if (ArmyGroup.FSMMgr == null)
        {
            ArmyGroup.FSMMgr = FSMManager.Instance;
        }
        this.bNpcMode = false;
        if (WarManager.IsNpcModeEnable)
        {
            if (heroID != 0)
            {
                Hero recordByKey = DataManager.Instance.HeroTable.GetRecordByKey(heroID);
                if (recordByKey.HeroKey == heroID && recordByKey.Summary != 0)
                {
                    this.bNpcMode = true;
                }
            }
            if (side != 0)
            {
                texColor = 2;
            }
        }
        this.DataIndex    = index;
        this.Side         = side;
        this.Tier         = tier;
        this.GroupKind    = groupKind;
        this.TextureColor = texColor;
        GameObject gameObject = new GameObject("ArmyGroup");

        this.groupRoot = gameObject.transform;
        if (FSMManager.Instance.bIsSiegeMode && this.Side == 1)
        {
            this.bAttackMode = false;
        }
        if (groupKind == EGroupKind.Cavalry)
        {
            this.RowCount = 2;
        }
        else if (groupKind == EGroupKind.Catapults)
        {
            this.RowCount         = 1;
            this.hitPointOffset.y = 1.5f;
        }
        else if (groupKind == EGroupKind.Archer)
        {
            this.hitPointOffset.y = 1f;
        }
        int num = (int)(groupKind - EGroupKind.Infantry);

        this.MoveSpeed = ArmyGroup.ConstSoldierSpeed[num];
        if (!this.bNpcMode)
        {
            this.SoldierCount        = (int)ArmyGroup.ConstSoldierCount[num];
            this.CurrentSoldierCount = (int)ArmyGroup.ConstSoldierCount[num];
            this.SoldierCountDefault = this.SoldierCount;
            this.soldierArray        = new Vector3[this.SoldierCount];
            this.soldiers            = new Soldier[this.SoldierCount];
            this.setupSoldierArray(groupKind);
        }
        else
        {
            this.SoldierCount        = 1;
            this.CurrentSoldierCount = 1;
            this.SoldierCountDefault = 1;
            this.soldierArray        = new Vector3[this.SoldierCount];
            this.soldiers            = new Soldier[this.SoldierCount];
            this.soldierArray[0]     = Vector3.zero;
        }
        int sceneLightmapSize = LightmapManager.Instance.SceneLightmapSize;
        int num2 = 2 + sceneLightmapSize;

        this.groupRoot.localScale = new Vector3(scaleFactor * 1f, scaleFactor * 1f, scaleFactor * 1f);
        for (int i = 0; i < this.SoldierCount; i++)
        {
            this.soldiers[i] = new Soldier((byte)groupKind, tier, texColor);
            GameObject gameObject2 = this.soldiers[i].gameObject;
            this.soldiers[i].renderer.lightmapIndex = num2;
            this.soldiers[i].Parent        = this;
            this.soldiers[i].Index         = (ushort)i;
            this.soldiers[i].FSMController = ArmyGroup.FSMMgr.getState(EStateName.IDLE);
            this.soldiers[i].pListener     = new Soldier.ParentListener(this.SoldierCallBack);
            gameObject2.transform.parent   = renderRoot;
            Vector3 position = this.targetPosition + this.groupRoot.TransformPoint(this.soldierArray[i]);
            gameObject2.transform.position   = position;
            gameObject2.transform.rotation   = Quaternion.LookRotation(this.groupRoot.forward);
            gameObject2.transform.localScale = new Vector3(scaleFactor, scaleFactor, scaleFactor);
            if (this.bNpcMode)
            {
                this.soldiers[i].renderer.enabled = false;
                this.soldiers[i].EnableShadow     = false;
            }
        }
        this.lightmapIndex = num2;
        if (heroID != 0)
        {
            this.heroSoldier = new Lord(heroID, (byte)groupKind, tier, this.Side, hasLord, this.DataIndex);
            this.heroSoldier.renderer.lightmapIndex = 255;
            this.heroSoldier.Parent             = this;
            this.heroSoldier.Index              = 255;
            this.heroSoldier.transform.parent   = renderRoot;
            this.heroSoldier.transform.position = this.groupRoot.TransformPoint(this.HeroOffset);
            this.heroSoldier.FSMController      = ArmyGroup.FSMMgr.getState(EStateName.IDLE);
            this.HasHeroDisplay = true;
        }
        this.m_State = ArmyGroup.EGROUPSTATE.IDLE;
    }