public void DoesNotSeeEnemy(HumanoidModel enemy) { EnemyTarget enemyTarget; viewableEnemies.TryGetValue(enemy, out enemyTarget); if (enemyTarget != null) { viewableEnemies.Remove(enemy); EnemyMarker newMarker = new EnemyMarker(enemyTarget, this); CommunicatableEnemyMarker newCMarker = new CommunicatableEnemyMarker( newMarker, checkHiddenEnemyRadius ); // avoid clustering enemy markers in one spot if (NoMarkerTooCloseTo(newCMarker)) { AddHiddenEnemy(newCMarker); HumanoidTargeterCommunication.Communicate( new CommunicationPackage( GetDeepCopyOfHiddenEnemies(), this ) ); } } }
public void SeesEnemy(HumanoidModel enemy, Vector3 location) { /* * first remove the nearest enemy marker that is in range * if seeing enemy for the first time */ EnemyTarget target = null; viewableEnemies.TryGetValue(enemy, out target); if (target == null) { foreach (CommunicatableEnemyMarker marker in hiddenEnemies) { if (Vector3.Distance(location, marker.GetEnemyMarker().GetLocation()) < hiddenEnemyRadius) { marker.Invalidate(); HumanoidTargeterCommunication.Communicate( new CommunicationPackage( GetDeepCopyOfHiddenEnemies(), this ) ); RemoveHiddenEnemy(marker); break; } } } // next add viewable enemy viewableEnemies[enemy] = new EnemyTarget(enemy, location); }
public EnemyMarker(HumanoidModel target, Vector3 location, HumanoidTargeter founder) { this.location = location; this.target = target; usedBy = new HashSet <HumanoidTargeter>(); enemyVantage = target.InfoGetVantageData(); enemyVantage.SetLocation(location); }
public override void CreateParts() { HumanoidModel humanoid = (HumanoidModel)game.ModelCache.Models[0].Instance; vertices = humanoid.vertices; Set = humanoid.Set; Set64 = humanoid.Set64; SetSlim = humanoid.SetSlim; }
public void StopSightStress(HumanoidModel aggressor) { ChronicStressor stressor = null; sightStressors.TryGetValue(aggressor, out stressor); if (stressor != null) { RemoveChronicStressor(stressor); } sightStressors.Remove(aggressor); }
public bool InfoCanSee(HumanoidModel other) { Vector3 thisVantagePoint = GetVantagePoint(); Vector3 otherVantagePoint = other.GetVantagePoint(); float distance = Vector3.Distance(thisVantagePoint, otherVantagePoint); if (distance > sightDistance) { return(false); } return(direction.WithinRangeOfVision(otherVantagePoint, visionWideness) && EnvironmentPhysics.LineOfSightToVantagePointExists( visionSharpness, thisVantagePoint, otherVantagePoint )); }
public virtual void EffectOnSeeEnemy(HumanoidModel enemy) { Vector3 thisVantagePoint = GetVantagePoint(); Projectile thisWeapon = currentWeapon.GetProjectile(); Vector3 enemyVantagePoint = enemy.GetVantagePoint(); Projectile enemyWeapon = enemy.currentWeapon.GetProjectile(); TerrainDisparity terrainDisparity = EnvironmentPhysics.CalculateTerrainDisparityBetween( thisWeapon, enemyWeapon, thisVantagePoint, enemyVantagePoint ); float coverDisparity = terrainDisparity.visibleToTarget - terrainDisparity.visibleToObserver; // the following line prevents advantageous cover from decreasing stress coverDisparity = coverDisparity < 0 ? 0 : coverDisparity; baseStressManager.PendSightStress(coverDisparity, enemy); }
public void PendSightStress(float coverDisparity, HumanoidModel aggressor) { ChronicStressor stressor = null; sightStressors.TryGetValue(aggressor, out stressor); if (stressor == null) { stressor = StressorFactory.CreateSightStressor(coverDisparity, coverDisparityModifier); sightStressors.Add(aggressor, stressor); AddChronicStressor(stressor); } else { ChronicStressor newStressor = StressorFactory.CreateSightStressor(coverDisparity, coverDisparityModifier); stressor.ModifySeverity(newStressor.GetSeverity()); } }
protected virtual void Awake() { _rigidbody2D = GetComponent <Rigidbody2D>(); HumanoidModel = GetComponent <HumanoidModel>(); }
public override void EffectOnSeeEnemy(HumanoidModel enemy) { base.EffectOnSeeEnemy(enemy); targeter.SeesEnemy(enemy, enemy.InfoGetCenterBottom()); }
public override void EffectDoesNotSeeEnemy(HumanoidModel enemy) { base.EffectDoesNotSeeEnemy(enemy); targeter.DoesNotSeeEnemy(enemy); }
public HumanoidTaskExecuter(HumanoidModel model) { this.model = model; }
public void EffectBenefitFromCloseness(HumanoidModel friend) { float distance = (centerBottom.position.x - friend.centerBottom.position.x) + (centerBottom.position.y - friend.centerBottom.position.y); }
public virtual void EffectDoesNotSeeEnemy(HumanoidModel enemy) { baseStressManager.StopSightStress(enemy); }
public EnemyTarget(HumanoidModel target, Vector3 location) { this.location = location; this.target = target; }