コード例 #1
0
ファイル: GlobalLine.cs プロジェクト: Paulgherve1/Critters
    public void AddIcon(GlobalWarning.subType newSubType, Sprite newSprite, Color32 newColor)
    {
        if (!sprites.Contains(newSprite))
        {
            sprites.Add(newSprite);
            colors.Add(newColor);

            PopulateIcons();
        }
    }
コード例 #2
0
    public static void DisableWarning(GlobalWarning targetWarning)
    {
        if (targetWarning == activeEVENTWarning)                            { activeEVENTWarning = null; }
        else if (targetWarning == activeFOODWarning)                        { activeFOODWarning = null; }
        else if (targetWarning == activeLOCOWarning)                        { activeLOCOWarning = null; }
        else if (targetWarning == activePOPWarning)                         { activePOPWarning = null; }
        else if (targetWarning == activeRESTRICTWarning)                    { activeRESTRICTWarning = null; }
        else if (targetWarning == activeSCOREWarning)                       { activeSCOREWarning = null; }

        totalWarnings--;
        RemoveWarningFromList(targetWarning);
        ArrangeWarnings();
    }
コード例 #3
0
ファイル: GlobalLine.cs プロジェクト: Paulgherve1/Critters
    public void Activate(GlobalWarning parent, Hex newHab, GlobalWarning.subType[] newSubTypes, Sprite[] newSprites, Color32[] newColors)
    {
        habitat = newHab;
        parentWarning = parent;

        GenerateContent(parentWarning.GetWarningType());

        for(int i = 0; i < newSubTypes.Length; i++) {
            GlobalWarning.subType item = newSubTypes[i];

            subInfo.Add(item);
            AddIcon(item, newSprites[i], newColors[i]);
        }

        SetTextPos(newSprites.Length);
    }
コード例 #4
0
 private void DropInNewWarning(GlobalWarning item)
 {
     item.DropIn();
 }
コード例 #5
0
    private void CreateNewGlobal(Hex newHab, GlobalWarning.warningType newType, GlobalWarning.subType[] newSubType, Sprite[] newSprite, Color32[] newColor)
    {
        Vector3 startPos = new Vector3(GetNewWarningXLocation(), 72, 0);
        Quaternion rotation = new Quaternion(0, -24, 180, 0);

        GameObject warningObject = Instantiate(prefab, startPos, rotation) as GameObject;
        GlobalWarning globalWarn = warningObject.GetComponent<GlobalWarning>();

        warningObject.transform.SetParent(warningsPanel.transform, false);
        globalWarn.Activate(newHab, newType, newSubType, newSprite, DetermineSpriteColor(newType, newSubType));

        RegisterNewWarning(globalWarn, newType);
        totalWarnings++;
        ArrangeWarnings();
        DropInNewWarning(globalWarn);
    }
コード例 #6
0
 private static void RemoveWarningFromList(GlobalWarning warning)
 {
     activeWarnings.Remove(warning);
     activeWarnings.TrimExcess();
 }
コード例 #7
0
    private static GlobalWarning GetActiveWarning(GlobalWarning.warningType newType)
    {
        GlobalWarning activeWarning = null;

        if (newType == GlobalWarning.warningType.EVENT)
        {
            if (activeEVENTWarning)
            {
                activeWarning = activeEVENTWarning;
            }
        }
        else if(newType == GlobalWarning.warningType.FOOD)
        {
            if (activeFOODWarning)
            {
                activeWarning = activeFOODWarning;
            }
        }
        else if (newType == GlobalWarning.warningType.LOCO)
        {
            if (activeLOCOWarning)
            {
                activeWarning = activeLOCOWarning;
            }
        }
        else if (newType == GlobalWarning.warningType.POP)
        {
            if (activePOPWarning)
            {
                activeWarning = activePOPWarning;
            }
        }
        else if (newType == GlobalWarning.warningType.RESTRICT)
        {
            if (activeRESTRICTWarning)
            {
                activeWarning = activeRESTRICTWarning;
            }
        }
        else if (newType == GlobalWarning.warningType.SCORE)
        {
            if (activeSCOREWarning)
            {
                activeWarning = activeSCOREWarning;
            }
        }

        return activeWarning;
    }
コード例 #8
0
    private static Color32[] DetermineSpriteColor(GlobalWarning.warningType newType, GlobalWarning.subType[] newSubType)
    {
        Color32 color = new Color32(255, 255, 255, 255);
        Color32[] colors = new Color32[newSubType.Length];

        for (int i = 0; i < newSubType.Length; i++)
        {
        if (newType == GlobalWarning.warningType.EVENT) { colors[i] = color; }
            else if (newType == GlobalWarning.warningType.POP) { colors[i] = color; }
            else if (newType == GlobalWarning.warningType.RESTRICT) { colors[i] = color; }
            else if (newType == GlobalWarning.warningType.SCORE) { colors[i] = color; }

            else if (newType == GlobalWarning.warningType.FOOD) { colors[i] = IconController.GetfoodColors()[(int)TranslateDietSubtype(newSubType[i])]; }
            else if (newType == GlobalWarning.warningType.LOCO) { colors[i] = IconController.GetLocoColors()[(int)TranslateLocoSubtype(newSubType[i])]; }
        }

        return colors;
    }
コード例 #9
0
    public void SelectWarningType(GlobalWarning newWarning)
    {
        HideAllWarnings();

        selectedWarning = newWarning;

        if (newWarning != null) {
            panelHeader.text = GlobalWarning.GetWarningTypeString(selectedWarning.GetWarningType());
            selectedWarning.PopulatePanel();
        }
    }
コード例 #10
0
    public void AddWarning(Hex newHab, GlobalWarning.warningType newType, GlobalWarning.subType[] newSubType, Sprite[] newSprite)
    {
        GlobalWarning activeWarning = GetActiveWarning(newType);

        if (activeWarning)
        {
            activeWarning.Activate(newHab, newType, newSubType, newSprite, DetermineSpriteColor(newType, newSubType));
        }
        else
        {
            CreateNewGlobal(newHab, newType, newSubType, newSprite, DetermineSpriteColor(newType, newSubType));
        }
    }
コード例 #11
0
 public static Critter.locomotionType TranslateLocoSubtype(GlobalWarning.subType type)
 {
     if (type == GlobalWarning.subType.AMPHIBIOUS) { return Critter.locomotionType.AMPHIBIOUS; }
     else if (type == GlobalWarning.subType.AQUATIC) { return Critter.locomotionType.AQUATIC; }
     else if (type == GlobalWarning.subType.AVIAN) { return Critter.locomotionType.AVIAN; }
     else { return Critter.locomotionType.TERRESTRIAL; }
 }
コード例 #12
0
 public static Critter.dietType TranslateDietSubtype(GlobalWarning.subType type)
 {
     if (type == GlobalWarning.subType.FISH) { return Critter.dietType.FISH; }
     else if (type == GlobalWarning.subType.INSECT) { return Critter.dietType.INSECT; }
     else if (type == GlobalWarning.subType.MEAT) { return Critter.dietType.CARNO; }
     else if (type == GlobalWarning.subType.PLANT) { return Critter.dietType.HERB; }
     else { return Critter.dietType.SCAV; }
 }
コード例 #13
0
    public static void EndWarning(Hex newHab, GlobalWarning.warningType newType)
    {
        GlobalWarning activeWarning = GetActiveWarning(newType);

        if (activeWarning)
        {
            activeWarning.RemoveWarning(newHab);
        }

        ArrangeWarnings();
    }
コード例 #14
0
ファイル: GlobalLine.cs プロジェクト: Paulgherve1/Critters
    public void RemoveIcon(GlobalWarning.subType newSubType)
    {
        if (subInfo.Contains(newSubType))
        {
            sprites.RemoveAt(subInfo.IndexOf(newSubType));
            colors.RemoveAt(subInfo.IndexOf(newSubType));
            subInfo.Remove(newSubType);
            subInfo.TrimExcess();
            sprites.TrimExcess();
            colors.TrimExcess();

            PopulateIcons();
        }

        SetTextPos(subInfo.Count);
    }
コード例 #15
0
    private void RegisterNewWarning(GlobalWarning newWarning, GlobalWarning.warningType newType)
    {
        if (newType == GlobalWarning.warningType.EVENT)                     { activeEVENTWarning = newWarning; }
        else if (newType == GlobalWarning.warningType.FOOD)                 { activeFOODWarning = newWarning; }
        else if (newType == GlobalWarning.warningType.LOCO)                 { activeLOCOWarning = newWarning; }
        else if (newType == GlobalWarning.warningType.POP)                  { activePOPWarning = newWarning; }
        else if (newType == GlobalWarning.warningType.RESTRICT)             { activeRESTRICTWarning = newWarning; }
        else if (newType == GlobalWarning.warningType.SCORE)                { activeSCOREWarning = newWarning; }

        activeWarnings.Add(newWarning);
    }
コード例 #16
0
 public void DeactivateDetailsPanel()
 {
     detailsPanel.gameObject.SetActive(false);
     selectedWarning.HideWarnings();
     selectedWarning = null;
 }
コード例 #17
0
ファイル: GlobalLine.cs プロジェクト: Paulgherve1/Critters
    private void GenerateContent(GlobalWarning.warningType warnType)
    {
        textContent = GetComponentInChildren<Text>();
        mainType = warnType;
        critter = FindObjectOfType<Player>().GetCritter();

        string text = "";

        if (warnType == GlobalWarning.warningType.EVENT)
        {
            float val = habitat.GetRiskFactor() * 100;

            if (val != 0) { text = "DANGER: " + val + "%"; }
            else { text = "NO DANGER"; }
        }
        else if (warnType == GlobalWarning.warningType.FOOD)
        {
            Critter.dietType target = critter.GetWeakestDiet(habitat);
            float val = habitat.GetFoodHealth(target);

            text = "FOOD AVAILABILITY: " + Hex.GetFoodHealthString(val);
        }
        else if (warnType == GlobalWarning.warningType.LOCO)
        {
            text = "CAN'T SURVIVE:  ";
        }
        else if (warnType == GlobalWarning.warningType.POP)
        {
            text = UpdatePOP();
        }
        else if (warnType == GlobalWarning.warningType.RESTRICT)
        {
            text = "RESTRICTIONS: ";
        }
        else if (warnType == GlobalWarning.warningType.SCORE)
        {
            float val = critter.CritterSurvivalCheck(habitat);

            text = "HABITABILITY: " + Critter.GetSurvivalChanceString(val);
        }

            textContent.text = text;
    }