コード例 #1
0
    //Pre-Initialisation
    private void Awake()
    {
        //Double check that the tag Canister exists and then apply it to this object
        this.gameObject.tag = "Canister";

        system = GameObject.FindGameObjectWithTag("Base_System").GetComponent <Base_System>();


        //None by default as it will be changed later
        canisterType = FluxType.NONE;

        //Every canister starts with the charge of Zero || 1
        charge = 0;

        chargeSlider.gameObject.SetActive(false);
        //Start Colour
        sliderFill.color = Color.white;
        //
        onlyCheckOnce = false;

        canisterMaterial = GetComponent <Renderer>().materials[1];

        //canisterMaterial.SetColor("_canisterColour", Color.red);
        //canisterMaterial.SetFloat("_canisterLevel", 0.5f);
    }
コード例 #2
0
ファイル: Converter.cs プロジェクト: 20154530/IpgwCore
        /// <summary>
        /// 将流量表示为 M G 的形式
        /// </summary>
        public static string FluxFormat(double value, FluxType type = FluxType.KB)
        {
            switch (type)
            {
            case FluxType.Bit:
                value *= 8;
                return(FormatByte(value));

            case FluxType.B:
                return(FormatByte(value));

            case FluxType.KB:
                if (value > 1000000)
                {
                    return(String.Format("{0:###.##}  G", value / 1000000.0));
                }
                else if (value > 1000)
                {
                    return(String.Format("{0:###.##}  M", value / 1000.0));
                }
                else
                {
                    return(String.Format("{0:###.##}  K", value));
                }

            case FluxType.MB:
                if (value > 1000)
                {
                    return(String.Format("{0:###.##}  G", value / 1000.0));
                }
                else
                {
                    return(String.Format("{0:###.##}  M", value));
                }

            default: return("<0>");
            }
        }