Exemple #1
0
        public void UpdateAutoMerge()
        {
            if (this.m_autoMergeTime > 0)
            {
                int autoMergeGroupSize = this.GetCharacterData().GetAutoMergeGroupSize();
                int autoMergeDistance  = this.GetCharacterData().GetAutoMergeDistance();

                if (autoMergeGroupSize > 0)
                {
                    LogicArrayList <LogicGameObject> characters = this.GetGameObjectManager().GetGameObjects(LogicGameObjectType.CHARACTER);
                    LogicCharacter closestCharacter             = null;

                    for (int i = 0; i < characters.Size(); i++)
                    {
                        LogicCharacter character = (LogicCharacter)characters[i];

                        if (character != this)
                        {
                            if (character.GetData() == this.GetData())
                            {
                                if (this.m_autoMergeSize == 0 && character.m_autoMergeSize >= autoMergeGroupSize)
                                {
                                    if (character.GetHitpointComponent().GetTeam() == this.GetHitpointComponent().GetTeam() && character.IsAlive())
                                    {
                                        if (character.m_autoMergeTime > 0)
                                        {
                                            int distanceSquared = this.GetPosition().GetDistanceSquared(character.GetPosition());

                                            if (distanceSquared <= autoMergeDistance * autoMergeDistance)
                                            {
                                                closestCharacter = character;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }

                    if (closestCharacter != null)
                    {
                        closestCharacter.m_autoMergeSize += 1;
                        closestCharacter.GetCombatComponent().SetMergeDamage(90 * closestCharacter.m_autoMergeSize);
                        closestCharacter.GetHitpointComponent()
                        .SetMaxHitpoints(closestCharacter.GetCharacterData().GetHitpoints(this.m_upgradeLevel) * (closestCharacter.m_autoMergeSize + 1));
                        closestCharacter.GetHitpointComponent()
                        .SetHitpoints(closestCharacter.GetCharacterData().GetHitpoints(this.m_upgradeLevel) * (closestCharacter.m_autoMergeSize + 1));

                        this.GetGameObjectManager().RemoveGameObject(this);
                    }
                }
            }
        }