public static void Show(Text ResourceText, ResourceStat resource) { if (resource != null) { ResourceText.text = resource.value.ToString(); } }
public void UpdateText() { IResourceManager itemManager = DIContainer.GetModule <IResourceManager>(); ResourceStat resource = itemManager.getResourceNeed(name); if (resource != null) { text.text = resource.value.ToString(); } }
public bool AddResourceNeed(TypeOfResource.Type type, float Value) { ResourceStat resourceNeed = getResourceNeed(type); if (resourceNeed != null && Value > 0) { resourceNeed.AddValue(Value); SaveResouce(); return(true); } return(false); }
public bool ReduceResourceNeed(string type, float Value) { ResourceStat resourceNeed = getResourceNeed(type); if (resourceNeed != null && Value > 0) { resourceNeed.ReduceValue(Value); SaveResource(type); return(true); } return(false); }
/// <summary> /// Load all resource to list dictionary. /// Luu toan bo tai nguyen vao list dictionary /// </summary> private void LoadAllResource() { resourceList = new Dictionary <string, ResourceStat>(); foreach (string str in Enum.GetNames(typeof(TypeOfResource.Type))) { TypeOfResource type = new TypeOfResource { type = TypeOfResource.ConvertStringToEnum(str) }; ResourceStat resource = new ResourceStat(PlayerPrefs.GetFloat(str, 0), type); resourceList.Add(str, resource); } }
/// <summary> /// Save each element based on type of resource. /// Luu moi phan tu dua vao loai tai nguyen /// </summary> private void SaveResource(string str) { ResourceStat resource = getResourceNeed(str); if (resource != null) { PlayerPrefs.SetFloat(str, getResourceNeed(str).value); } else { PlayerPrefs.SetFloat(str, 0); } }
public bool AddResourceNeed(string type, float Value) { ResourceStat resourceNeed = getResourceNeed(type); if (resourceNeed != null && Value > 0) { Debug.Log("Run"); resourceNeed.AddValue(Value); SaveResource(type); return(true); } return(false); }
public string[] GenerateAuditText() { // dialogue for ewan to say List<string> dialogue = new List<string>(); dialogue.Add( "Congratulations on upgrading your Town Hall to Level Two. You can now upgrade all your entities to Level Two as well."); dialogue.Add( "Now that I'm here, I might as well take a look at your island and resources to give you some feedback on how your going !"); var resourceTypes = Enum.GetValues(typeof(ResourceType)).Cast<ResourceType>(); foreach (ResourceType resource in resourceTypes) { ResourceStat stat = resources.GetResourceBalanceFor(resource); int supply = stat.supply; int demand = stat.demand; int overall = supply - demand; AuditLevels auditLevels = null; switch (resource) { case ResourceType.Environment: auditLevels = audit.Environment; break; case ResourceType.Food: auditLevels = audit.Food; break; case ResourceType.Power: auditLevels = audit.Power; break; case ResourceType.Shelter: auditLevels = audit.Shelter; break; } string resourceDialogue = GetAuditForResource(auditLevels, overall); dialogue.Add(resourceDialogue); } dialogue.Add( "I'll be off now. Good luck on your journey in maintaining a healthy, prosperous and sustainable island. Remember, once you hit Level Three, you can unlock some special entities..."); return dialogue.ToArray(); }
/// <summary> /// This function save all Resource. /// Chuc nang nay luu tat ca cac resource lai /// </summary> private void SaveAllResource() { foreach (string str in Enum.GetNames(typeof(TypeOfResource.Type))) { ResourceStat resource = getResourceNeed(str); if (resource != null) { PlayerPrefs.SetFloat(str, getResourceNeed(str).value); } else { PlayerPrefs.SetFloat(str, 0); } } }
public void LoadResource() { // TO DO somethin.... string[] s = PlayerPrefsX.GetStringArray(KeySave.ALL_RESOURCE); for (int i = 0; i < s.Length; i++) { string[] temp = s[i].Split(','); Debug.Log(s[i].ToString()); if (temp.Length > 0 && temp.Length <= 2) { TypeOfResource type = new TypeOfResource { type = (TypeOfResource.Type) int.Parse(temp[0]) }; float.TryParse(temp[1], out float value); ResourceStat resource = getResourceNeed(type.type); resource.value = value; } } }
protected override void OnManaDepletion(ResourceStat stat) { base.OnManaDepletion(stat); }
public void AddPrice(ResourceStat price) { }
public void ShowHint(ResourceStat stat) { gameObject.SetActive(true); hint.text = string.Format(msg, stat.supply, stat.demand); }