Ejemplo n.º 1
0
 public void removeEntity(FOWEntity e)
 {
     if (entities.Contains(e))
     {
         entities.Remove(e);
     }
 }
Ejemplo n.º 2
0
    // Use this for initialization
    public override void Start()
    {
        base.Start();

        if (GameObject.FindGameObjectWithTag("minimap_cam"))
        {
            mainCam = GameObject.FindGameObjectWithTag("minimap_cam").GetComponent <Camera>();
        }
        else
        {
            Debug.LogWarning("There is no minimap camera!");
        }
        fe       = gameObject.GetComponent <FOWEntity>();
        box_text = null;

        creation_tex    = new Texture2D(32, 32);
        creation_tex    = (Texture2D)Resources.Load("creation");
        underAttack_tex = new Texture2D(32, 32);
        underAttack_tex = (Texture2D)Resources.Load("underAttack");

        creation_ON = true;

        isOnSight      = false;
        onSightIdx     = 0;
        onSightTimer   = 0f;
        onSightTexture = new Texture2D(32, 32);
        onSightTexture = (Texture2D)Resources.Load("redcross");

        res = Screen.currentResolution.width;
    }
Ejemplo n.º 3
0
 public void addEntity(FOWEntity e)
 {
     if (!entities.Contains(e))
     {
         entities.Add(e);
     }
 }
Ejemplo n.º 4
0
    protected void activateFOWEntity()
    {
        FOWEntity fe = gameObject.AddComponent <FOWEntity>();

        fe.Range = info.attributes.sightRange;
        fe.Activate(info.race);
        gameObject.AddComponent <EntityMarker>();         // For the mini-map
    }
Ejemplo n.º 5
0
    public virtual void Start()
    {
        //moves the revealer to the orbitating position

        transform.position = transform.parent.position;
        _race = transform.parent.GetComponent <Barrack>().getRace();
        //_attacker = transform.parent.GetComponent<Unit>();

        _revealer = GetComponent <FOWEntity>();
        _revealer.Activate(_race);

        _light    = transform.parent.FindChild("LightHouse-Detector").gameObject;
        _attacker = transform.parent.FindChild("LightHouse-Detector").GetComponent <Unit>();
        _light.SetActive(false);

        transform.parent.GetComponent <Barrack>().register(Barrack.Actions.BUILDING_FINISHED, OnBuildingFinished);
        transform.parent.GetComponent <Barrack>().register(Barrack.Actions.DESTROYED, OnBuildingDestroyed);
        _target = null;
    }
Ejemplo n.º 6
0
    public virtual void Start()
    {
        //moves the revealer to the orbitating position

        transform.position = transform.parent.position;
        _race = transform.parent.GetComponent<Barrack>().getRace();
        //_attacker = transform.parent.GetComponent<Unit>();

        _revealer = GetComponent<FOWEntity>();
        _revealer.Activate(_race);

        _light = transform.parent.FindChild("LightHouse-Detector").gameObject;
        _attacker = transform.parent.FindChild("LightHouse-Detector").GetComponent<Unit>();
        _light.SetActive(false);

        transform.parent.GetComponent<Barrack>().register(Barrack.Actions.BUILDING_FINISHED, OnBuildingFinished);
        transform.parent.GetComponent<Barrack>().register(Barrack.Actions.DESTROYED, OnBuildingDestroyed);
        _target = null;

    }
Ejemplo n.º 7
0
    public static List <Unit> getVisibleUnitsNotOfRaceNearPosition(Vector3 position, float radius, Storage.Races race)
    {
        GameObject[] foundGameObjects = getObjectsNearPosition(position, radius);
        List <Unit>  unitsOfRace      = new List <Unit>();

        for (int i = 0; i < foundGameObjects.Length; i++)
        {
            GameObject obj       = foundGameObjects[i];
            Unit       objUnit   = obj.GetComponent <Unit>();
            FOWEntity  fowEntity = obj.GetComponent <FOWEntity>();

            if (objUnit == null || fowEntity == null)
            {
                continue;
            }

            if (objUnit.race != race && objUnit.status != EntityStatus.DEAD && fowEntity.IsRevealed)
            {
                unitsOfRace.Add(objUnit);
            }
        }
        return(unitsOfRace);
    }
Ejemplo n.º 8
0
 public void removeEntity(FOWEntity e)
 {
     if (entities.Contains(e))
         entities.Remove(e);
 }
Ejemplo n.º 9
0
 public void addEntity(FOWEntity e)
 {
     if (!entities.Contains(e))
         entities.Add(e);
 }
Ejemplo n.º 10
0
    /// <summary>
    /// Reveals an area around the entity passed as paramater
    /// </summary>
    /// <param name="entity">Entity which reveals an area</param>
    private void reveal(FOWEntity entity)
    {
        Color32[] table;
        int range = Mathf.RoundToInt(entity.Range*Quality);

        if (!rangeTables.TryGetValue(range,out table))
        {
            table = makeTable(entity.Range);
            rangeTables.Add(range, table);
        }
        Vector2 center = entity.Bounds.center*Quality;
        float xOff = center.x - range;
        float yOff = center.y - range;
        int xCen = Mathf.RoundToInt(xOff);
        int yCen = Mathf.RoundToInt(yOff);
        int texWidth = fowTex.width;
        int dRange = range * 2;
        if(xCen > 0 && yCen > 0)
        {
            if (entity.IsOwnedByPlayer)
            {
                Vector2 offset = new Vector2(xOff - xCen, yOff - yCen);
                for (int x = 0; x <= dRange; x++)
                {
                    for (int y = 0; y <= dRange; y++)
                    {
                        int n = x + y * dRange;
                        int n2 = (xCen+x) + (yCen+y) * texWidth;
                        if (n2 < pixels.Length)
                        {

                            if (table[n].b > 0)
                            {
                                if (table[n].b == 255)
                                {
                                    pixels[n2].b = (byte)Mathf.Max(pixels[n2].b, table[n].b);
                                    pixels[n2].g = (byte)Mathf.Max(pixels[n2].g, table[n].g);
                                }
                                else
                                {
                                    int valOff = Mathf.RoundToInt(offset.x * (x - range) + offset.y * (y - range));
                                    pixels[n2].b = (byte)Mathf.Max(pixels[n2].b, Mathf.Min(table[n].b + valOff, 255));
                                    pixels[n2].g = (byte)Mathf.Max(pixels[n2].g, Mathf.Min(table[n].g + valOff, 255));
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                for (int x = 0; x <= dRange; x++)
                {
                    for (int y = 0; y <= dRange; y++)
                    {
                        int n = x + y * dRange;
                        int n2 = (xCen + x) + (yCen + y) * texWidth;
                        if (n2 < pixels.Length && table[n].b > 1)
                        {
                            aiVision[n2] = (visible.explored | visible.visible);
                        }
                    }
                }
            }
        }
    }
Ejemplo n.º 11
0
    /// <summary>
    /// Reveals an area around the entity passed as paramater
    /// </summary>
    /// <param name="entity">Entity which reveals an area</param>
    private void reveal(FOWEntity entity)
    {
        Color32[] table;
        int       range = Mathf.RoundToInt(entity.Range * Quality);

        if (!rangeTables.TryGetValue(range, out table))
        {
            table = makeTable(entity.Range);
            rangeTables.Add(range, table);
        }
        Vector2 center   = entity.Bounds.center * Quality;
        float   xOff     = center.x - range;
        float   yOff     = center.y - range;
        int     xCen     = Mathf.RoundToInt(xOff);
        int     yCen     = Mathf.RoundToInt(yOff);
        int     texWidth = fowTex.width;
        int     dRange   = range * 2;

        if (xCen > 0 && yCen > 0)
        {
            if (entity.IsOwnedByPlayer)
            {
                Vector2 offset = new Vector2(xOff - xCen, yOff - yCen);
                for (int x = 0; x <= dRange; x++)
                {
                    for (int y = 0; y <= dRange; y++)
                    {
                        int n  = x + y * dRange;
                        int n2 = (xCen + x) + (yCen + y) * texWidth;
                        if (n2 < pixels.Length)
                        {
                            if (table[n].b > 0)
                            {
                                if (table[n].b == 255)
                                {
                                    pixels[n2].b = (byte)Mathf.Max(pixels[n2].b, table[n].b);
                                    pixels[n2].g = (byte)Mathf.Max(pixels[n2].g, table[n].g);
                                }
                                else
                                {
                                    int valOff = Mathf.RoundToInt(offset.x * (x - range) + offset.y * (y - range));
                                    pixels[n2].b = (byte)Mathf.Max(pixels[n2].b, Mathf.Min(table[n].b + valOff, 255));
                                    pixels[n2].g = (byte)Mathf.Max(pixels[n2].g, Mathf.Min(table[n].g + valOff, 255));
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                for (int x = 0; x <= dRange; x++)
                {
                    for (int y = 0; y <= dRange; y++)
                    {
                        int n  = x + y * dRange;
                        int n2 = (xCen + x) + (yCen + y) * texWidth;
                        if (n2 < pixels.Length && table[n].b > 1)
                        {
                            aiVision[n2] = (visible.explored | visible.visible);
                        }
                    }
                }
            }
        }
    }