private InformationNMCanFirePosition GetInfo(AIBrain ai) { InformationNMCanFirePosition infoRetVal = null; List <InformationNMCanFirePosition> infos = ai.GetSensor <SensorCanFireNMPositionFinder>().RequestAllInfo(ai); if (infos == null || infos.Count == 0) { return(null); } float closest = Mathf.Infinity; foreach (var info in infos) { if (Mathf.Abs(tryMoveAngle - info.angle.Value) < closest) { infoRetVal = info; closest = Mathf.Abs(tryMoveAngle - info.angle.Value); } } if (Mathf.Abs(lastAngle - infoRetVal.angle.Value) > 90 || _dirChangeTime < 0) { tryMoveAngle = -tryMoveAngle; lastAngle = tryMoveAngle; tryMoveAngle = 90 * Mathf.Sign(tryMoveAngle) + Mathf.Sign(tryMoveAngle) * (tryMoveAngleOfTargetHealthMinMax.x + ai.InfoCurrentTarget.health.Confidence * (tryMoveAngleOfTargetHealthMinMax.y - tryMoveAngleOfTargetHealthMinMax.x)); _dirChangeTime = Random.Range(dirChangeRandTimeMinMax.x, dirChangeRandTimeMinMax.y); } return(infoRetVal); }
public override bool CanBeAddedToPlan(AIBrain ai) { if (ai.GetSensor <SensorCanFireNMPositionFinder>().RequestAllInfo(ai) == null) { return(false); } float chance = 0; if (ai.WorldState.CompareKey(DS.takingBulletDamage, true)) { chance = applicapableChanceInBetweenPerc.y; } else { chance = applicapableChanceInBetweenPerc.x; } if ( Random.Range(0, 100) < chance && ai.HaveCurrentTarget() && ai.HaveCurrentWeapon() ) { return(true); } return(false); }
public override bool CanActivate(AIBrain ai) { infoMoveSide = ai.GetSensor <SensorCanFireNMPositionFinder>().RequestInfo(ai); if (infoMoveSide != null && ai.HaveCurrentWeapon() && ai.HaveCurrentTarget()) { return(true); } return(false); }
public override void OnStart(AIBrain ai) { AddNeededStateSystem <AIStateSystemAnimator>(); AddNeededSensor <SensorDodgeSideFinder>(); repeatType = ET.ActionType.Once; sensorSideFinder = ai.GetSensor <SensorDodgeSideFinder>(); preConditions.Add(DS.takingBulletDamage, true); postEffects.Add(DS.bulletDodged, true); correspondingState = ET.StateType.Animate; }
public override bool IsApplicapable(AIBrain ai) { bool applyChance = false; if (Time.time - lastUsedAt > minIntervalToSetApplicapable && UnityEngine.Random.Range(0, 100) < activatablePercentage) { applyChance = true; } bool retval = ai.WorldState.CompareKey(DS.haveTarget, true) && ai.WorldState.CompareKey(DS.takingBulletDamage, true) && ai.HaveCurrentTarget() && ai.GetSensor <SensorDodgeSideFinder>().RequestInfo <InformationDodgeSide>(ai) != null && applyChance; if (retval) { lastUsedAt = Time.time; } return(retval); }
private void GetMovePos(AIBrain ai) { List <InformationNMCanFirePosition> infos = ai.GetSensor <SensorCanFireNMPositionFinder>().RequestAllInfo(ai); if (infos != null && infos.Count > 0) { float maxConf = -1; foreach (var info in infos) { float distFromSelf = Vector3.Distance(ai.Transform.position, info.positionEstimated.Value); float distSelfConf = 1 - Mathf.Clamp01(distFromSelf / 10); float distFromTarget = Vector3.Distance(ai.GetCurrentTargetPos(), info.positionEstimated.Value); float distTargetConf = Mathf.Clamp01(distFromTarget / 10); float tempOveralConf = (distSelfConf + distTargetConf) / 2; if (tempOveralConf > maxConf) { infoMovePos = info; maxConf = tempOveralConf; } } } }
public override bool CanActivate(AIBrain ai) { checkingInfo = ai.Memory.Items.OfType <InformationSuspicion>().Where(x => /*!x.IsSure &&*/ !x.LastPositionChecked).OrderByDescending(x => x.UpdateTime).FirstOrDefault(); bool retVal = false; if (checkingInfo != null) { infoCheckPositions = ai.GetSensor <SensorRandPosAroundGtor>().RequestAllInfo(checkingInfo.lastKnownPosition.Value); } if (infoCheckPositions != null) { retVal = true; if (infoCheckPositions.Count > maxRandCheckPos) { infoCheckPositions.RemoveAll(x => infoCheckPositions.IndexOf(x) >= maxRandCheckPos); } } if (retVal) { checkingInfo.IsBeingUsed = true; } return(retVal); }
public override bool CanActivate(AIBrain ai) { return(ai.HaveCurrentTarget() && ai.GetSensor <SensorCanFireNMPositionFinder>().RequestInfo(ai) != null); }