Пример #1
0
    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
                        )
                    );
            }
        }
    }
Пример #2
0
    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);
    }
Пример #3
0
 public EnemyMarker(HumanoidModel target, Vector3 location, HumanoidTargeter founder)
 {
     this.location = location;
     this.target   = target;
     usedBy        = new HashSet <HumanoidTargeter>();
     enemyVantage  = target.InfoGetVantageData();
     enemyVantage.SetLocation(location);
 }
Пример #4
0
        public override void CreateParts()
        {
            HumanoidModel humanoid = (HumanoidModel)game.ModelCache.Models[0].Instance;

            vertices = humanoid.vertices;
            Set      = humanoid.Set;
            Set64    = humanoid.Set64;
            SetSlim  = humanoid.SetSlim;
        }
Пример #5
0
    public void StopSightStress(HumanoidModel aggressor)
    {
        ChronicStressor stressor = null;

        sightStressors.TryGetValue(aggressor, out stressor);
        if (stressor != null)
        {
            RemoveChronicStressor(stressor);
        }
        sightStressors.Remove(aggressor);
    }
Пример #6
0
    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
                   ));
    }
Пример #7
0
    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);
    }
Пример #8
0
    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());
        }
    }
Пример #9
0
 protected virtual void Awake()
 {
     _rigidbody2D  = GetComponent <Rigidbody2D>();
     HumanoidModel = GetComponent <HumanoidModel>();
 }
Пример #10
0
 public override void EffectOnSeeEnemy(HumanoidModel enemy)
 {
     base.EffectOnSeeEnemy(enemy);
     targeter.SeesEnemy(enemy, enemy.InfoGetCenterBottom());
 }
Пример #11
0
 public override void EffectDoesNotSeeEnemy(HumanoidModel enemy)
 {
     base.EffectDoesNotSeeEnemy(enemy);
     targeter.DoesNotSeeEnemy(enemy);
 }
Пример #12
0
 public HumanoidTaskExecuter(HumanoidModel model)
 {
     this.model = model;
 }
Пример #13
0
 public void EffectBenefitFromCloseness(HumanoidModel friend)
 {
     float distance = (centerBottom.position.x - friend.centerBottom.position.x)
                      + (centerBottom.position.y - friend.centerBottom.position.y);
 }
Пример #14
0
 public virtual void EffectDoesNotSeeEnemy(HumanoidModel enemy)
 {
     baseStressManager.StopSightStress(enemy);
 }
Пример #15
0
 public EnemyTarget(HumanoidModel target, Vector3 location)
 {
     this.location = location;
     this.target   = target;
 }