Ejemplo n.º 1
0
        private void UpdateMergeGroups()
        {
            //This follows the same code design pattern used in Split Manager. It's a very stable way of cleaning/updating the lists
            //this manager manages.
            if (this.mergeList.Count > 0)
            {
                for (int i = 0; i < this.mergeList.Count; i++)
                {
                    MergeGroup group = this.mergeList[i];
                    if (group.elapsedTime > 1f)
                    {
                        group.Resume();
                        if (!this.removeList.Contains(group))
                        {
                            FinishMergeGroup(group);
                            this.removeList.Add(group);

                            GameMetricLogger.Increment(GameMetricOptions.Merges);
                        }
                    }
                    else
                    {
                        group.Update(this.scalingValue);
                        group.elapsedTime += Time.deltaTime / group.mergeSpeedFactor;
                        this.mergeList[i]  = group;
                    }
                }
            }

            if (this.removeList.Count > 0)
            {
                foreach (MergeGroup group in this.removeList)
                {
                    if (this.mergeList.Contains(group))
                    {
                        this.mergeList.Remove(group);
                    }
                }
                this.removeList.Clear();
            }
        }
Ejemplo n.º 2
0
        private void HandleAttacking()
        {
            if (this.properties.targetUnit != null && this.attackCooldownCounter <= 0 && !this.properties.isAttackCooldownEnabled)
            {
                CmdAttack(this.hasAuthority, this.gameObject, this.properties.targetUnit, 1);
                this.attackCooldownCounter = 1f;
                NewChanges changes = this.CurrentProperty();
                changes.isAttackCooldownEnabled = true;
                this.NewProperty(changes);

                GameMetricLogger.Increment(GameMetricOptions.Attacks);
            }
            else if (this.attackCooldownCounter > 0f)
            {
                NewChanges changes = this.CurrentProperty();
                changes.isAttackCooldownEnabled = true;
                this.NewProperty(changes);

                GameMetricLogger.Increment(GameMetricOptions.AttackTime);
            }
        }
Ejemplo n.º 3
0
 private void LogKill()
 {
     GameMetricLogger.Increment(GameMetricOptions.Kills);
 }
Ejemplo n.º 4
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();
            }
        }