コード例 #1
0
        public void EjectCharacters()
        {
            LogicArrayList <LogicComponent> components = this.GetComponentManager().GetComponents(LogicComponentType.MOVEMENT);

            int ejectHousingSpace = this.GetTrapData().GetEjectHousingLimit(this.m_upgLevel);
            int radius            = this.GetTrapData().GetTriggerRadius();

            for (int i = 0; i < components.Size(); i++)
            {
                LogicMovementComponent movementComponent = (LogicMovementComponent)components[i];
                LogicGameObject        parent            = movementComponent.GetParent();

                if (parent.GetGameObjectType() == LogicGameObjectType.CHARACTER)
                {
                    LogicCharacter character = (LogicCharacter)parent;

                    if (character.GetHitpointComponent() != null && character.GetHitpointComponent().GetTeam() == 0 &&
                        character.GetCharacterData().GetHousingSpace() <= ejectHousingSpace)
                    {
                        int distanceX = character.GetX() - this.GetMidX();
                        int distanceY = character.GetY() - this.GetMidY();

                        if (LogicMath.Abs(distanceX) <= radius &&
                            LogicMath.Abs(distanceY) <= radius)
                        {
                            if (character.GetCombatComponent() == null || character.GetCombatComponent().GetUndergroundTime() <= 0)
                            {
                                int distanceSquared = distanceX * distanceX + distanceY * distanceY;

                                if (distanceSquared < (uint)(radius * radius))
                                {
                                    character.Eject(null);
                                    ejectHousingSpace -= character.GetCharacterData().GetHousingSpace();
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #2
0
        public void ThrowCharacters()
        {
            LogicArrayList <LogicComponent> components = this.GetComponentManager().GetComponents(LogicComponentType.MOVEMENT);

            int ejectHousingSpace = this.GetTrapData().GetEjectHousingLimit(this.m_upgLevel);
            int radius            = this.GetTrapData().GetTriggerRadius();

            for (int i = 0; i < components.Size(); i++)
            {
                LogicMovementComponent movementComponent = (LogicMovementComponent)components[i];
                LogicGameObject        parent            = movementComponent.GetParent();

                if (parent.GetGameObjectType() == LogicGameObjectType.CHARACTER)
                {
                    LogicCharacter character = (LogicCharacter)parent;

                    if (character.GetHitpointComponent() != null && character.GetHitpointComponent().GetTeam() == 0 &&
                        character.GetCharacterData().GetHousingSpace() <= ejectHousingSpace)
                    {
                        int distanceX = character.GetX() - this.GetMidX();
                        int distanceY = character.GetY() - this.GetMidY();

                        if (LogicMath.Abs(distanceX) <= radius &&
                            LogicMath.Abs(distanceY) <= radius)
                        {
                            if (character.GetCombatComponent() == null || character.GetCombatComponent().GetUndergroundTime() <= 0)
                            {
                                int distanceSquared = distanceX * distanceX + distanceY * distanceY;

                                if (distanceSquared < (uint)(radius * radius))
                                {
                                    int activeLayout = this.m_level.GetActiveLayout();
                                    int direction    = activeLayout <= 7 ? this.m_direction[activeLayout] : 0;
                                    int pushBackX    = 0;
                                    int pushBackY    = 0;

                                    switch (direction)
                                    {
                                    case 0:
                                        pushBackX = 256;
                                        break;

                                    case 1:
                                        pushBackY = 256;
                                        break;

                                    case 2:
                                        pushBackX = -256;
                                        break;

                                    case 3:
                                        pushBackY = -256;
                                        break;
                                    }

                                    this.m_level.AreaPushBack(this.GetMidX(), this.GetMidY(), 600, 1000, 1, 1, pushBackX, pushBackY, this.GetTrapData().GetThrowDistance(),
                                                              ejectHousingSpace);
                                }
                            }
                        }
                    }
                }
            }
        }