Пример #1
0
    public bool AddToConstruction(ID.Specification spec, ID.Type type, int var)
    {
        for (int i = 0; i < IO.Inputs.Length; i++)
        {
            if (IO.Inputs[i].GetComponent <ID>().Compare(spec, type, var))
            {
                if (IO.InputCheck[i] == false)
                {
                    IO.InputCheck[i] = true;

                    /*
                     * bool requirementsComplete = true;
                     * for (int j = 0; j < IO.InputCheck.Length; j++)
                     * {
                     *  if (IO.InputCheck[j] == false) requirementsComplete = false;
                     * }
                     *
                     * if(requirementsComplete)
                     * {
                     *  Construct();
                     * }*/
                    Construct();

                    return(true);
                }
            }
        }


        return(false);
    }
    public void AdjustWarmthValue(float value, bool fireSource, ID.Specification spec)
    {
        // could do for >0 (Remove it), i would have to make fireplace +2 though so it actually increases. (THIS COULD WORK!)
        if (value < 0)
        {
            switch (_WarmthState)
            {
            case WarmthState.Hot:
                value *= 3f;
                break;

            case WarmthState.Neutral:
                value *= 2f;
                break;

            case WarmthState.Cold:
                value *= 1f;
                break;
            }
            if (_DayNightCycle._DayState == DayNightCycle.DayState.Night)
            {
                value *= 1.5f;
            }
            // value = Mathf.RoundToInt(1 + (0.1f * (_WarmthValue - 10f)));
            // Debug.Log("Val: " + value);
        }
        else if (value > 0)
        {
            switch (_WarmthState)
            {
            case WarmthState.Hot:
                value /= 7f;
                break;

            case WarmthState.Neutral:
                value /= 5f;
                break;

            case WarmthState.Cold:
                value /= 3f;
                break;
            }
            if (_DayNightCycle._DayState == DayNightCycle.DayState.Night)
            {
                value *= 1.5f;
            }
        }

        //Debug.Log(value);

        if (fireSource && _WarmthState == WarmthState.Hot)
        {
            if (_WarmthValue + value >= 89)
            {
                _WarmthValue = 87;
                value        = 0;
            }
            // return;
        }

        if (spec == ID.Specification.WoodenTorch && _WarmthState == WarmthState.Cold)
        {
            // CANT GET ANY WARMER THAN COLD IF COLD
            if (_WarmthValue + value >= 25)
            {
                _WarmthValue = 25;
                value        = 0;
                // return;
            }
        }

        if (_MainPlayerStats.playerWithinShelter)
        {
            if (_WarmthState == WarmthState.Cold || _WarmthState == WarmthState.Freezing)
            {
                // Debug.Log("HUH: " +  _WarmthValue);
                if (_WarmthValue <= 10f || (_WarmthValue + value) <= 10f)
                {
                    //    Debug.Log("HUH2");
                    _WarmthValue = 11;
                    value        = 0;
                }
            }
        }



        if (_DayNightCycle._DayState != DayNightCycle.DayState.Night)
        {
            //Debug.Log("000H");
            if (_WarmthState == WarmthState.Cold || _WarmthState == WarmthState.Freezing)
            {
                // Debug.Log("HUH: " +  _WarmthValue);
                if (_WarmthValue <= 10f || (_WarmthValue + value) <= 10f)
                {
                    //    Debug.Log("HUH2");
                    _WarmthValue = 11;
                    value        = 0;
                }
            }
        }


        if (_WarmthState == WarmthState.Freezing && _DayNightCycle._DayState == DayNightCycle.DayState.Night)
        {
            // value *= 300;
        }

        _WarmthValue += value;

        if (_WarmthValue < 0)
        {
            _WarmthValue = 0;
        }
        if (_WarmthValue > 100)
        {
            _WarmthValue = 100;
        }

        if (_WarmthValue <= 10)
        {
            _WarmthState = WarmthState.Freezing;
        }
        if (_WarmthValue > 10 && _WarmthValue <= 25)
        {
            _WarmthState = WarmthState.Cold;
        }
        if (_WarmthValue > 25 && _WarmthValue <= 50)
        {
            _WarmthState = WarmthState.Neutral;
        }
        if (_WarmthValue < 90 && _WarmthValue >= 75)
        {
            _WarmthState = WarmthState.Hot;
        }
        if (_WarmthValue >= 90)
        {
            _WarmthState = WarmthState.Boiling;
        }

        /*if(_WarmthValue == 0)
         * {
         *  Debug.Log("DIE!");
         *  GameManager.Instance.Die();
         * }*/

        switch (_WarmthState)
        {
        case WarmthState.Freezing:
            _WarmthBar.rectTransform.GetChild(0).GetComponent <Text>().text = "Freezing";
            Color32 icey = new Color32(182, 243, 255, 255);
            _WarmthBar.rectTransform.GetComponent <Image>().color = icey;
            break;

        case WarmthState.Cold:
            _WarmthBar.rectTransform.GetChild(0).GetComponent <Text>().text = "Cold";
            Color32 bluey = new Color32(124, 233, 255, 255);
            _WarmthBar.rectTransform.GetComponent <Image>().color = bluey;
            break;

        case WarmthState.Neutral:
            _WarmthBar.rectTransform.GetChild(0).GetComponent <Text>().text = "Neutral";
            _WarmthBar.rectTransform.GetComponent <Image>().color           = _OriginalWarmthColour;
            break;

        case WarmthState.Hot:
            _WarmthBar.rectTransform.GetChild(0).GetComponent <Text>().text = "Hot";
            _WarmthBar.rectTransform.GetComponent <Image>().color           = Color.magenta;
            break;

        case WarmthState.Boiling:
            _WarmthBar.rectTransform.GetChild(0).GetComponent <Text>().text = "Boiling";
            _WarmthBar.rectTransform.GetComponent <Image>().color           = Color.red;
            break;
        }
    }