Exemplo n.º 1
0
        public override void Process()
        {
            List <CollisionComponent> components = ComponentStorage <CollisionComponent> .Components;

            for (int y = 0; y < components.Count; y++)
            {
                if (Config.ShowCollisionRectangle)
                {
                    DrawCollisionRect(components[y]);
                }

                CollisionComponent first = components[y];

                for (int i = 0; i < components.Count; i++)
                {
                    CollisionComponent second = components[i];

                    if (first != second && first.Group != second.Group)
                    {
                        if (CheckCollision(first, second) == true)
                        {
                            int  firstDamage    = 0;
                            bool canFirstAttack = first.CanAttack;
                            if (canFirstAttack)
                            {
                                firstDamage = first.Attack();
                            }

                            if (second.CanAttack)
                            {
                                first.Collision(second.Attack());
                            }

                            if (canFirstAttack)
                            {
                                second.Collision(firstDamage);
                            }
                        }
                    }
                }
            }
        }