Exemplo n.º 1
0
 public override void Update()
 {
     base.Update();
     foreach (Unit unit in Game.Unit_List)
     {
         if (unit == Caster)
         {
             continue;
         }
         IPair delta  = Pos - unit.Pos;
         int   radius = (RADIUS + unit.Radius) * GameDef.PIXEL_SCALE;
         if (delta.LengthSquare() > radius * radius || delta.Zero())
         {
             continue;
         }
         delta.ChangeLength(STRENGTH);
         unit.AddRepulse(delta);
     }
     foreach (Missile missile in Game.Missile_List)
     {
         if (missile.Caster == Caster)
         {
             continue;
         }
         IPair delta  = Pos - missile.Pos;
         int   radius = (RADIUS + missile.Radius) * GameDef.PIXEL_SCALE;
         if (delta.LengthSquare() > radius * radius || delta.Zero())
         {
             continue;
         }
         delta.ChangeLength(STRENGTH);
         missile.AddRepulse(delta);
     }
 }
Exemplo n.º 2
0
        public virtual void CheckCollision(Unit unit)
        {
            IPair delta            = pos_ - unit.Pos;
            int   collision_radius = (radius_ + unit.Radius) * GameDef.PIXEL_SCALE;

            if (delta.LengthSquare() > collision_radius * collision_radius)
            {
                return;
            }
            if (caster_ == unit)
            {
                if (hurt_self_)
                {
                    Collision = true;
                }
            }
            else
            {
                Collision = true;
                if (explode_enemy_)
                {
                    Explode = true;
                }
            }
        }
Exemplo n.º 3
0
        public override void Cast(Unit unit, IPair destination, Effect[] effect_list)
        {
            base.Cast(unit, destination, effect_list);
            IPair delta = destination - unit.Pos;

            if (delta.LengthSquare() > MAX_RANGE * MAX_RANGE)
            {
                delta.ChangeLength(MAX_RANGE);
            }
            unit.Pos.Add(delta);
        }
Exemplo n.º 4
0
        //  collision
        public virtual void CheckCollision(Missile missile)
        {
            if (caster_ == missile.caster_)
            {
                return;
            }
            IPair delta            = pos_ - missile.pos_;
            int   collision_radius = (radius_ + missile.radius_) * GameDef.PIXEL_SCALE;

            if (delta.LengthSquare() > collision_radius * collision_radius)
            {
                return;
            }
            if (explode_enemy_missile_ && missile.explode_enemy_missile_)
            {
                Explode = Collision = missile.Explode = missile.Collision = true;
            }
        }
Exemplo n.º 5
0
        public override void Cast(Unit unit, IPair destination, Effect[] effect_list)
        {
            base.Cast(unit, destination, effect_list);
            foreach (Unit u in Game.Unit_List)
            {
                IPair delta  = unit.Pos - u.Pos;
                int   radius = (RADIUS + unit.Radius) * GameDef.PIXEL_SCALE;
                if (delta.LengthSquare() <= radius * radius)
                {
                    if (unit == u)
                    {
                        u.Hp -= DAMAGE;
                        if (u.Hp <= 0)
                        {
                            u.Hp = 1;
                        }
                    }
                    else
                    {
                        u.Damage(unit.Owner, unit.Pos, DAMAGE);
                    }
                }
            }
            foreach (Missile missile in Game.Missile_List)
            {
                if (missile.Caster == unit)
                {
                    continue;
                }
                IPair delta  = unit.Pos - missile.Pos;
                int   radius = (RADIUS + missile.Radius) * GameDef.PIXEL_SCALE;
                if (delta.LengthSquare() <= radius * radius)
                {
                    if (missile.ExplodeEnemyMissile)
                    {
                        missile.Explode = true;
                    }
                }
            }
            EFRedemption effect = new EFRedemption();

            effect.Pos.Clone(unit.Pos);
            effect.Register();
        }
Exemplo n.º 6
0
        public void CheckHurt(Unit unit)
        {
            IPair delta            = pos_ - unit.Pos;
            int   collision_radius = (radius_ + unit.Radius) * GameDef.PIXEL_SCALE;

            if (delta.LengthSquare() > collision_radius * collision_radius)
            {
                return;
            }
            if (caster_ == unit)
            {
                if (hurt_self_)
                {
                    unit.Damage(caster_.Owner, pos_, damage_);
                }
            }
            else
            {
                unit.Damage(caster_.Owner, pos_, damage_);
            }
        }