示例#1
0
        private void ManageLists()
        {
            if (this.splitList.Count > 0)
            {
                for (int i = this.splitList.Count - 1; i >= 0; i--)
                {
                    Split splitGroup = this.splitList[i];
                    if (splitGroup.owner == null || splitGroup.split == null)
                    {
                        this.splitList.Remove(splitGroup);
                    }
                    if (splitGroup.elapsedTime > 1f)
                    {
                        NewGameUnit unit = splitGroup.owner.GetComponent <NewGameUnit>();
                        this.changes             = unit.CurrentProperty();
                        this.changes.isSelected  = false;
                        this.changes.isSplitting = false;
                        CmdUpdateUnitProperty(splitGroup.owner.gameObject, this.changes);
                        unit = splitGroup.split.GetComponent <NewGameUnit>();
                        CmdUpdateUnitProperty(splitGroup.split.gameObject, this.changes);
                        this.unitList.Add(new NewUnitStruct(splitGroup.split.gameObject));
                        this.splitList.Remove(splitGroup);

                        GameMetricLogger.Increment(GameMetricOptions.Splits);
                    }
                    else
                    {
                        splitGroup.Update();
                        this.splitList[i] = splitGroup;
                    }
                }
            }
            if (this.mergeList.Count > 0)
            {
                for (int i = this.mergeList.Count - 1; i >= 0; i--)
                {
                    Merge mergeGroup = this.mergeList[i];
                    if (mergeGroup.elapsedTime > 1f)
                    {
                        if (mergeGroup.owner != null)
                        {
                            NewGameUnit unit = mergeGroup.owner.gameObject.GetComponent <NewGameUnit>();
                            this.changes            = unit.CurrentProperty();
                            this.changes.isMerging  = false;
                            this.changes.isSelected = false;
                            //changes.newLevel = unit.properties.level + 1;
                            CmdUpdateUnitProperty(mergeGroup.owner.gameObject, this.changes);
                        }
                        if (mergeGroup.merge != null)
                        {
                            NewUnitStruct temp = new NewUnitStruct();
                            temp.unit = mergeGroup.merge.gameObject;
                            this.unitList.Remove(temp);
                            CmdDestroy(temp.unit);
                        }
                        this.mergeList.RemoveAt(i);

                        GameMetricLogger.Increment(GameMetricOptions.Merges);
                    }
                    else
                    {
                        mergeGroup.Update();
                        this.mergeList[i] = mergeGroup;
                    }
                }
            }
            this.isUnitListEmpty = this.unitList.Count <= 0;
            if (!this.isUnitListEmpty)
            {
                for (int i = this.unitList.Count - 1; i >= 0; i--)
                {
                    if (this.unitList[i].unit == null)
                    {
                        this.unitList.RemoveAt(i);
                        continue;
                    }
                    NetworkIdentity id = this.unitList[i].unit.GetComponent <NetworkIdentity>();
                    if (!id.hasAuthority)
                    {
                        CmdRemoveUnitList(this.unitList[i].unit);
                    }
                }
            }
            else
            {
                CmdShowReport();
            }
        }