protected virtual void hitPerson(PersonEntity person) { person.beHit(this, 1); if (null != this.shallow) { this.shallow.addPerson(person); } if (!this._repeat) { this.hitList.Add(person); } this.bomb(); }
public virtual void bomb() { if (!this.enabled || !this._alived) { return; } if (this.bangRadiusMax > 0) { //爆炸范围只承受部分伤害,排除已经Hit伤害过的 int radius = this._shape.radius; this._shape.radius = this.bangRadiusMax; //TODO:这里没有指定敌方我方。 List <PersonEntity> personList = this._map.getPerson(this._shape); for (int i = 0, len = personList.Count; i < len; i++) { PersonEntity person = personList[i]; if (!this.hitList.Contains(person)) { double bangRate; if (this.bangRateMin == this.bangRateMax) { bangRate = this.bangRateMin; } else { double dist = Collision.realPosition(this._position, person.position, this._map.mapData).deltaPos.length - person.shape.radius; if (dist <= this.bangRadiusMin) { bangRate = this.bangRateMin; } else { bangRate = (dist - this.bangRadiusMin) / (this.bangRadiusMax - this.bangRadiusMin) * (this.bangRateMax - this.bangRateMin) + this.bangRateMin; } } //仅爆炸的子弹,替代命中检测方案 if (!this._repeat && this._hitAction == null) { this.hitList.Add(person); } person.beHit(this, bangRate); } } this._shape.radius = radius; } //这里要写碰撞的次数。 if (this._lifeTime <= 0) { this.clear(); } else { this.bangCount--; if (this.bangCount == 0) { this.clear(); } } }