コード例 #1
0
ファイル: UserForm.cs プロジェクト: jac259/NutritionAssistant
        private void cboWeightChange_SelectedIndexChanged(object sender, EventArgs e)
        {
            ComboBox cbo = sender as ComboBox;

            if (cbo != null)
            {
                WeightChange wgtchg = (WeightChange)cboWeightChange.SelectedIndex;
                AutoCalories();
                unsaved         = true;
                btnSave.Enabled = unsaved;
            }
        }
コード例 #2
0
    private void LoadFromXML(XmlNode info)
    {
        bool   success = true;
        string reason  = "";

        XmlAttribute xmlAttr = info.Attributes ["for"];

        if (xmlAttr != null)
        {
            listenFor_ = XMLHelper.FetchString(xmlAttr);
        }
        else
        {
            success = false;
            reason  = "listener created, but no 'for' defined " + info.OuterXml;
        }

        if (success)
        {
            XmlNodeList content = info.ChildNodes;
            foreach (XmlNode xmlItem in content)
            {
                if (xmlItem.Name == "weight")
                {
                    weightChange_ = new WeightChange(xmlItem);
                }
                else
                {
                    success = false;
                    reason  = "listener effect invalid, found " + xmlItem.Name + " was expecting (weight)";
                }

                if (!success)
                {
                    break;
                }
            }
        }


        if (!success)
        {
            Debug.LogError("Error loading listener XML: " + reason + " " + info.OuterXml);
        }
    }
コード例 #3
0
    IEnumerator PickUp(Collider2D player) //find first link of chain and change it's break limit also changes to new spawnpoint and new prefab to unchained player
    {
        _ColorCode.SetSpawnPoint(spawnPointFree);
        _ColorCode.SetPlayerPrefab(freePlayer);
        chainFirst     = GameObject.FindGameObjectsWithTag("ChainFirst");
        chainTemp      = (GameObject)chainFirst.GetValue(0);
        _WeightChange  = chainTemp.GetComponent <WeightChange>();
        _WeightChange2 = chainTemp.GetComponent <WeightChange>();

        oldWeight = _WeightChange.GetWeight();
        _WeightChange.SetWeight(newWeight);
        _WeightChange.SetBreak(breakValue);
        _WeightChange2.SetGravity(gravityValue);

        GetComponent <Collider2D>().enabled     = false;
        GetComponent <SpriteRenderer>().enabled = false;

        yield return(new WaitForSeconds(duration));

        _WeightChange.SetWeight(oldWeight);
        Destroy(gameObject);
    }
コード例 #4
0
ファイル: UserForm.cs プロジェクト: jac259/NutritionAssistant
        void AutoCalories()
        {
            if (rdoCalManual.Checked || !CalAutoValidate())
            {
                return;
            }

            string sex = cboSex.SelectedItem as string;
            string activity = cboActivity.SelectedItem as string;
            double weight_kg, height_m, modifier = 0.2;
            int    age;

            if (string.IsNullOrWhiteSpace(sex))
            {
                sex = currentUser.sex;
            }
            if (string.IsNullOrWhiteSpace(activity))
            {
                activity = currentUser.activity;
            }
            if (!double.TryParse(txtWeight.Text, out weight_kg))
            {
                weight_kg = currentUser.weight_kg;
            }
            if (!double.TryParse(txtHeight.Text, out height_m))
            {
                height_m = currentUser.height_m;
            }
            if (!int.TryParse(txtAge.Text, out age))
            {
                age = currentUser.age;
            }

            WeightChange wgtChg = (WeightChange)cboWeightChange.SelectedIndex;

            switch (wgtChg)
            {
            case WeightChange.Lose:
                modifier = 1 - modifier;
                break;

            case WeightChange.Maintain:
                modifier = 1;
                break;

            case WeightChange.Gain:
                modifier = 1 + modifier;
                break;
            }

            double BMR = -1;

            if (sex.ToLower() == "male")
            {
                BMR = (66 + 13.7 * weight_kg + 500 * height_m - 6.8 * age);
            }
            else if (sex.ToLower() == "female")
            {
                BMR = (655 + 9.6 * weight_kg + 180 * height_m - 4.7 * age);
            }
            else
            {
                txtCalories.Text = "2000";
                return;
            }

            txtCalories.Text = ((int)(BMR * User.HBF[activity] * modifier)).ToString();
        }
コード例 #5
0
 public void SetChain(GameObject chain)
 {
     _WeightChange  = chain.GetComponent <WeightChange>();
     _WeightChange2 = chain.GetComponent <WeightChange>();
 }
コード例 #6
0
    private void LoadFromXML(XmlNode info)
    {
        bool   success = true;
        string reason  = "";

        sleepFor_ = new IntNull();
        effects_  = new List <ResultEffect> ();

        XmlAttribute xmlAttr = info.Attributes ["type"];

        if (xmlAttr != null)
        {
            string tempString = XMLHelper.FetchString(xmlAttr);
            if (tempString == "success")
            {
                type_ = ResultType.Success;
            }
            else if (tempString == "failure")
            {
                type_ = ResultType.Failure;
            }
            else if (tempString == "success_crit")
            {
                type_ = ResultType.SuccessCrit;
            }
            else if (tempString == "failure_crit")
            {
                type_ = ResultType.FailureCrit;
            }
            else if (tempString == "any")
            {
                type_ = ResultType.Any;
            }
            else
            {
                success = false;
                reason  = "invalid type tag: '" + tempString + "', was looking for (success, failure, failure_crit, success_crit, any, or blank)";
            }
        }
        else
        {
            type_ = ResultType.Any;
        }

        xmlAttr = info.Attributes ["id"];
        if (xmlAttr != null)
        {
            id_ = XMLHelper.FetchString(xmlAttr);
        }

        if (success)
        {
            XmlNodeList content = info.ChildNodes;
            foreach (XmlNode xmlItem in content)
            {
                if (xmlItem.Name == "desc")
                {
                    if (desc_ == null)
                    {
                        desc_ = xmlItem.InnerText;
                    }
                    else
                    {
                        success = false;
                        reason  = "found multiple instances of <desc>";
                    }
                }
                else if (xmlItem.Name == "weight")
                {
                    weightChange_ = new WeightChange(xmlItem);
                }
                else if (xmlItem.Name == "never_again")
                {
                    neverAgain_ = XMLHelper.FetchBool(xmlItem);
                }
                else if (xmlItem.Name == "sleep_for")
                {
                    IntNull temp = XMLHelper.FetchIntNull(xmlItem);
                    if (temp.Value < 0)
                    {
                        success = false;
                        reason  = "invalid value for sleep_for. negative numbers not valid";
                    }
                    else
                    {
                        sleepFor_ = temp;
                    }
                }
                else if (xmlItem.Name == "effect")
                {
                    effects_.Add(new ResultEffect(xmlItem));
                }
                else
                {
                    success = false;
                    reason  = "invalid tag found for result: " + xmlItem.Name + ", was expecting desc, weight_inc, weight_set, never_again, effect";
                }

                if (!success)
                {
                    break;
                }
            }
        }

        if (!success)
        {
            Debug.LogError("Error loading result XML: " + reason);
        }
    }