예제 #1
0
    //TODO: differentiate between inventory items and map items
    //public GameObject[] allItemsOnMap;

    //creates a list of all positions fire will spread to
    //but doesn't set them on fire (used for fire indicator)
    //- returns positions for empty spaces as well but not occupied positions already on fire
    //returns List<Vector2Int> of position to set fire to
    //TODO: double check if actually works
    public List <Vector2Int> GetFireSpreadPositions()
    {
        GameObject[]      allItemsOnMap = TimeManagerScript.instance.allItemsOnGrid;
        List <Vector2Int> toFire        = SpreadFireHelper();

        toFire = toFire.Distinct().ToList();
        for (int i = toFire.Count - 1; i >= 0; i--)
        {
            for (int j = 0; j < allItemsOnMap.Length; j++)
            {
                ItemScript scr = allItemsOnMap[i].GetComponent <ItemScript>();
                if (scr.CompareToItemPosition(toFire[j]) && scr.isOnFire)
                {
                    toFire.Remove(toFire[j]);                     //remove if the current spot is occupied and on fire
                    break;
                }
            }
        }
        return(toFire);
    }
예제 #2
0
    //creates a list of all positions which fire can spread to
    //then checks if any flammable objects occupy that position
    //then sets em on fire
    public void SpreadFire()
    {
        GameObject[]      allItemsOnMap = TimeManagerScript.instance.allItemsOnGrid;
        List <Vector2Int> toFire        = SpreadFireHelper();

        toFire = toFire.Distinct().ToList();
        for (int i = 0; i < allItemsOnMap.Length; i++)
        {
            ItemScript scr = allItemsOnMap[i].GetComponent <ItemScript>();
            if (!scr.isOnFire && scr.isFlammable && scr.itemPos.x >= 0)              //only set to fire if it's flammable and not yet on fire
            {
                for (int j = 0; j < toFire.Count; j++)
                {
                    if (scr.CompareToItemPosition(toFire[j]))
                    {
                        scr.SetFire(true);
                        break;
                    }
                }
            }
        }
    }