Пример #1
0
        public static void NPCNeedFactory(Characters.Character character)
        {
            Debug.Log("In NPCNeedFactory");
            JSONNode j = Connect.GetJSONNode(new List <string> {
                "Need", "NeedData.json"
            });

            for (int i = 0; i < j["NPCNeed"].Count; i++)
            {
                Need charNeed = character.gameObject.AddComponent <Need>();

                //Debug.Log("name " + j["NPCNeed"][i]["needName"].Value);
                //Debug.Log("stati " + NeedStatusFactory(j, i));
                //Debug.Log("starting " + j["NPCNeed"][i]["startingValue"].AsInt);
                //Debug.Log("decrementvalue " + j["NPCNeed"][i]["valueDecrementRate"].AsInt);
                //Debug.Log("time " + j["NPCNeed"][i]["timeToDecrement"].AsInt);

                NeedData need = new NeedData(
                    j["NPCNeed"][i]["needName"].Value,
                    NeedStatusFactory(j, i),
                    j["NPCNeed"][i]["startingValue"].AsInt,
                    j["NPCNeed"][i]["valueDecrementRate"].AsInt,
                    j["NPCNeed"][i]["timeToDecrement"].AsInt
                    );
                charNeed.Init(need);
            }
        }
Пример #2
0
        //Constructor for MonoBehaviour object
        //Will have to resolve the Start method invoking an empty object
        public void Init(NeedData needData)
        {
            NeedName           = needData.NeedName;
            NeedStatuses       = needData.NeedStatuses;
            ValueDecrementRate = needData.ValueDecrementRate;
            TimeToDecrement    = needData.TimeToDecrement;
            CurrentValue       = needData.StartingValue;
            SetCurrentStatus();
            InvokeRepeating("DecrementCurrentValue", 0, needData.TimeToDecrement);

            Debug.Log(this.NeedName + " Init Completed");
        }