Exemple #1
0
    public static Well Factory(int cellID, bool full = true)
    {
        GameObject wellGO = GameObject.Instantiate((GameObject)Resources.Load("Prefabs/Tokens/Well")) as GameObject;
        Well       well   = wellGO.GetComponent <Well>();

        well.Cell = Cell.FromId(cellID);
        SpriteRenderer sr = well.GetComponent <SpriteRenderer>();

        if (sr != null)
        {
            sr.enabled = false;
        }

        if (well.Cell == null)
        {
            return(well);
        }

        well.goFullWell  = well.Cell.transform.Find("well/well-full").gameObject;
        well.goEmptyWell = well.Cell.transform.Find("well/well-empty").gameObject;

        if (full)
        {
            well.DisplayWell();
        }
        else
        {
            well.DisplayWell(true);
            well.Cell.Inventory.RemoveToken(well);
        }

        return(well);
    }