public const int STRENGTH = 50; // as 50 damage spell public MIHealBall(Unit caster, IPair destination) : base(80, caster) { radius_ = RADIUS; damage_ = -10; speed_ = 350; hurt_self_ = true; explode_enemy_ = false; explode_enemy_missile_ = false; Unit target = null; bool used = false; long min_distance = 0, temp_distance; foreach (Unit unit in Game.Unit_List) { if (unit == caster) { continue; } if (used == false) { used = true; target = unit; min_distance = (unit.Pos - Pos).LengthSquare(); } else { temp_distance = (unit.Pos - Pos).LengthSquare(); if (temp_distance < min_distance) { target = unit; min_distance = temp_distance; } } } if (target != null) { destination.Clone(target.Pos); } IPair delta = destination - caster.Pos; move_vector_ = delta.Clone(); move_vector_.ChangeLength(speed_); delta.ChangeLength(GameDef.UNIT_RADIUS * GameDef.PIXEL_SCALE); Pos.Clone(caster.Pos); Pos.Add(delta); }
// override public override void Update() { hp_ += GameDef.UNIT_RECOVER; hp_ = Math.Min(hp_, GameDef.UNIT_MAX_HP * GameDef.PIXEL_SCALE); // cd count for (int i = 0; i < GameDef.SPELL_COUNT; ++i) { if (cd_list_[i] > 0) { --cd_list_[i]; } } // move IPair delta = repusle_.Clone(); if (order_.Type == 1) { IPair move_vector = order_.Param1 - Pos; if (move_vector.LengthSquare() > speed_ * speed_) { move_vector.ChangeLength(speed_); } else { order_.Stop(); } delta.Add(move_vector); } // repusle decrease long repusle_length_square = repusle_.LengthSquare(); long repusle_decrease = speed_ >> GameDef.REPULSE_DECREASE_FACTOR; if (repusle_length_square < repusle_decrease * repusle_decrease) { repusle_.X = repusle_.Y = 0; } else { repusle_.ChangeLength((long)Math.Sqrt((double)repusle_length_square) - repusle_decrease); } Pos.Add(delta); GameDef.AdjustCollisionWall(Pos, Radius); }
// operator public void Damage(Player player, IPair pos, int damage) { hp_ -= damage; mp_ += damage; // 補血就賺囉 if (mp_ < 0) { mp_ = 0; } if (damage <= 0) { return; // heal } last_damage_ = player; IPair delta = pos_ - pos; if (delta.Zero() == false) { delta.ChangeLength((damage * 3 * (mp_ / GameDef.PIXEL_SCALE + 100) / 100) >> 1); repusle_.Add(delta); } }