Пример #1
0
        public virtual void Collide(BasicShipGameObject s)
        {
            if (!s.IsAlly(ParentUnit))
            {
                if (!BulletCanBounce || !s.BulletBounces(this))
                {
                    float Damage = getDamage(s, 1);
                    Damage *= ParentUnit.GetDamageMult();
                    s.Damage(Damage, PushTime * Damage, Speed * PushVelocityMult, ParentUnit, attackType);
                }
                else
                {
                    BulletHasBounced = true;

                    if (!BounceSound)
                    {
                        SoundManager.Play3DSound("ShieldBounce", new Vector3(Position.X(), Y, Position.Y()),
                                                 0.35f, 500, 1);
                        BounceSound = true;
                    }

                    if (s.GetType().IsSubclassOf(typeof(UnitBasic)))
                    {
                        UnitBasic b = (UnitBasic)s;
                        b.ShieldFlash(1);
                    }
                    Speed = Vector2.Reflect(Speed, Vector2.Normalize(s.Position.get() - PreviousPosition));
                    Position.set(PreviousPosition);
                    return;
                }
            }

            if (TargetHitCount < MaxHits)
            {
                if (TargetsHit == null)
                {
                    TargetsHit = new BasicShipGameObject[MaxHits];
                    TargetsHit[TargetHitCount++] = s;
                }
                else if (!TargetsHit.Contains(s))
                {
                    TargetsHit[TargetHitCount++] = s;
                }
                else
                {
                    return;
                }
            }
            else
            {
                Destroy();
            }
        }