예제 #1
0
    public bool TerrainCheck(Entity.TerrainType targetTerrain)
    {
        if (type == WeaponDiversityType.Torpedo)
        {
            return(targetTerrain == Entity.TerrainType.Ground);
        }

        return(this.terrain == Entity.TerrainType.All || targetTerrain == this.terrain);
    }
예제 #2
0
 public bool CheckCategoryCompatibility(Entity.TerrainType terrain, Entity.EntityCategory category)
 {
     if (type == WeaponDiversityType.Torpedo)
     {
         return(terrain == Entity.TerrainType.Ground);
     }
     else
     {
         return(TerrainCheck(terrain) &&
                CategoryCheck(category));
     }
 }
예제 #3
0
    public static T getNearestEntity <T>(Entity craft, bool enemy = true) where T : Entity
    {
        int faction = craft.faction;

        Entity.TerrainType terrainType = craft.Terrain;
        float minD    = float.MaxValue;
        T     nearest = null;

        for (int i = 0; i < AIData.entities.Count; i++)
        {
            if (AIData.entities[i] == craft)
            {
                continue;
            }
            if (AIData.entities[i].GetIsDead())
            {
                continue;
            }
            if (terrainType != Entity.TerrainType.All && AIData.entities[i].Terrain != terrainType)
            {
                continue;
            }
            if (AIData.entities[i].IsInvisible)
            {
                continue;
            }
            if (AIData.entities[i] is T)
            {
                if ((FactionManager.IsAllied(AIData.entities[i].faction, faction) ^ !enemy) && faction != -1)
                {
                    continue;
                }

                float d = (craft.transform.position - AIData.entities[i].transform.position).sqrMagnitude;
                if (d < minD)
                {
                    minD    = d;
                    nearest = AIData.entities[i] as T;
                }
            }
        }
        return(nearest);
    }
예제 #4
0
 public void SetTerrain(Entity.TerrainType terrain)
 {
     this.terrain = terrain;
 }