protected override void OnTargetTrigger(Bio target, int triggerIndex) { base.OnTargetTrigger(target, triggerIndex); EntityUtils.GetEntitiesInCircle(this._buff.battle.GetEntities(), this._buff.property.position, this._buff.radius, ref this._temp1); EntityUtils.FilterTarget(this._buff.caster, CampType.Hostile | CampType.Neutral, EntityFlag.Hero, ref this._temp1, ref this._temp2); if (this._temp2.Count > 0) { int index = this._buff.battle.random.Next(0, this._temp2.Count); //上限是闭区间 this.CreateMissile(( Bio )this._temp2[index]); } else { this._temp2.Clear(); EntityUtils.FilterTarget(this._buff.caster, CampType.Hostile, EntityFlag.SmallPotato, ref this._temp1, ref this._temp2); if (this._temp2.Count > 0) { int index = this._buff.battle.random.Next(0, this._temp2.Count); this.CreateMissile(( Bio )this._temp2[index]); } } this._temp1.Clear(); this._temp2.Clear(); }
protected override void OnUpdate(UpdateContext context) { FoxFire foxFire = ( FoxFire )this.owner; foxFire.property.Equal(Attr.Position, Vec3.Normalize(this.angleSpeed * (foxFire.property.position - this.caster.property.position)) * this.distance + this.caster.property.position); this._time += context.deltaTime; if (this._time < this._delay) { return; } this._time = 0f; EntityUtils.GetEntitiesInCircle(foxFire.battle.GetEntities(), foxFire.property.position, foxFire.detectRange, ref this._temp1); EntityUtils.FilterTarget(foxFire, CampType.Hostile | CampType.Neutral, EntityFlag.Hero, ref this._temp1, ref this._temp2); if (this._temp2.Count > 0) { int index = foxFire.battle.random.Next(0, this._temp2.Count); //上限是闭区间 foxFire.Emmit(( Bio )this._temp2[index]); } else { this._temp2.Clear(); EntityUtils.FilterTarget(foxFire, CampType.Hostile, EntityFlag.SmallPotato, ref this._temp1, ref this._temp2); if (this._temp2.Count > 0) { int index = foxFire.battle.random.Next(0, this._temp2.Count); foxFire.Emmit(( Bio )this._temp2[index]); } } this._temp1.Clear(); this._temp2.Clear(); }
private void SelectTargets(Bio mainTarget, bool detectInOut, ref List <Bio> result) { if (detectInOut) { this._tempOldTargets.AddRange(result); result.Clear(); } switch (this._buff.rangeType) { case RangeType.Single: //检查指定的目标是否符合条件 //在隐身等状态下也能选中,因此不能使用CanAttack方法 if (!mainTarget.isDead && EntityUtils.CheckCampType(this._buff.caster, this._buff.campType, mainTarget) && EntityUtils.CheckTargetFlag(this._buff.targetFlag, mainTarget)) { result.Add(mainTarget); } break; case RangeType.Circle: { bool targetAdded = false; if (mainTarget != null && EntityUtils.CanAttack(this._buff.caster, mainTarget, this._buff.campType, this._buff.targetFlag)) { targetAdded = true; result.Add(mainTarget); //如果指定的目标符合条件则优先添加到目标列表 } int maxTargetNum = mainTarget != null ? this._buff.maxTriggerTargets - 1 : this._buff.maxTriggerTargets; if (maxTargetNum > 0) { EntityUtils.GetEntitiesInCircle(this._buff.battle.GetEntities(), this._buff.property.position, this._buff.radius, ref this._temp1); if (targetAdded) { this._temp1.Remove(mainTarget); //之前已经添加目标了 } EntityUtils.FilterTarget(this._buff.caster, this._buff.campType, this._buff.targetFlag, ref this._temp1, ref this._temp2); this._temp1.Clear(); EntityUtils.FilterLimit(ref this._temp2, ref this._temp1, maxTargetNum); int count = this._temp1.Count; for (int i = 0; i < count; i++) { result.Add(( Bio )this._temp1[i]); } this._temp1.Clear(); this._temp2.Clear(); } } break; case RangeType.Sector: //todo break; } if (detectInOut) { int tc = result.Count; for (int i = 0; i < tc; i++) { Bio mTarget = result[i]; if (!this._tempOldTargets.Contains(mTarget)) { this._tempEnter.Add(mTarget); } } tc = this._tempOldTargets.Count; for (int i = 0; i < tc; i++) { Bio mTarget = this._tempOldTargets[i]; if (!result.Contains(mTarget)) { this._tempExit.Add(mTarget); } } this.HandleTargetInOut(this._tempEnter, this._tempExit); this._tempEnter.Clear(); this._tempExit.Clear(); this._tempOldTargets.Clear(); } }