Exemple #1
0
        private static void Main(string[] args)
        {
            warningType warning = (warningType)10;

            Console.WriteLine(warning);
            // normal
        }
    public static string GetWarningTypeString(warningType type)
    {
        string text = "";

        if (type == warningType.EVENT)                      { text = "LOCAL EVENTS"; }
        else if (type == warningType.FOOD)                  { text = "FOOD SHORTAGE"; }
        else if (type == warningType.LOCO)                  { text = "ADAPTATION CRISES"; }
        else if (type == warningType.POP)                   { text = "POPULATION DECLINE"; }
        else if (type == warningType.RESTRICT)              { text = "CAN'T SURVIVE!"; }
        else if (type == warningType.SCORE)                 { text = "INHOSPITABLE ENVIRONMENT"; }

        return text;
    }
    public void Activate(Hex newHab, warningType newType, subType[] newSubType, Sprite[] newSprite, Color32[] newColor)
    {
        if (!warnControl)
        {
            warnControl = FindObjectOfType<WarningsController>();
        }

        warning = newType;
        for (int i = 0; i < newSubType.Length; i++) {
            SetIcon(newSprite[0]);
            SetColor(newColor[0]);
        }

        AddWarning(newHab, newSubType, newSprite, newColor);
    }
    public void CreateWarning(warningType currentWarning, Sprite sprite, Color32 color)
    {
        Vector3 startPos = new Vector3(0, 10, 0);

        if (currentWarning == warningType.FOOD)
        {
            GameObject newWarning = Instantiate(Icon, startPos, Quaternion.identity) as GameObject;
            WarningIcon newScript = newWarning.GetComponent<WarningIcon>();

            newWarning.transform.SetParent(habitat.transform, false);
            newScript.Activate(critter, habitat, warningType.FOOD, sprite, color);
            activeFOODWarning = newWarning;
        }
        if (currentWarning == warningType.LOCO)
        {
            GameObject newWarning = Instantiate(Icon, startPos, Quaternion.identity) as GameObject;
            WarningIcon newScript = newWarning.GetComponent<WarningIcon>();

            newWarning.transform.SetParent(habitat.transform, false);
            newScript.Activate(critter, habitat, warningType.LOCO, sprite, color);
            activeLOCOWarning = newWarning;
        }
        if (currentWarning == warningType.POP){
            GameObject newWarning = Instantiate(Icon, startPos, Quaternion.identity) as GameObject;
            WarningIcon newScript = newWarning.GetComponent<WarningIcon>();

            newWarning.transform.SetParent(habitat.transform, false);
            newScript.Activate(critter, habitat, warningType.POP, sprite, color);
            activePOPWarning = newWarning;
        }
        if (currentWarning == warningType.RESTRICT)
        {
            GameObject newWarning = Instantiate(Icon, startPos, Quaternion.identity) as GameObject;
            WarningIcon newScript = newWarning.GetComponent<WarningIcon>();

            newWarning.transform.SetParent(habitat.transform, false);
            newScript.Activate(critter, habitat, warningType.RESTRICT, sprite, color);
            activeRESTRICTWarning = newWarning;
        }
        if (currentWarning == warningType.SCORE){
            GameObject newWarning = Instantiate(Icon, startPos, Quaternion.identity) as GameObject;
            WarningIcon newScript = newWarning.GetComponent<WarningIcon>();

            newWarning.transform.SetParent(habitat.transform, false);
            newScript.Activate(critter, habitat, warningType.SCORE, sprite, color);
            activeSCOREWarning = newWarning;
        }

        totalActiveWarnings++;
        ReorderWarningIcons();
    }
    public GameObject DetermineWarningByType(warningType type)
    {
        GameObject activeItem = null;

        if (type == warningType.FOOD) { activeItem = activeFOODWarning; }
        if (type == warningType.LOCO) { activeItem = activeLOCOWarning; }
        if (type == warningType.POP) { activeItem = activePOPWarning; }
        if (type == warningType.RESTRICT) { activeItem = activeRESTRICTWarning; }
        if (type == warningType.SCORE) { activeItem = activeSCOREWarning; }

        return activeItem;
    }