public void TakeDamage(float damage) { HalmetSettings halmet = Data.Instance.GetHalmetSettings(Data.Instance.CurrentHalmet); VestSettings vest = Data.Instance.GetVestSettings(Data.Instance.CurrentVest); print("halmet.HalmetStats.Resist: " + halmet.HalmetStats.Resistence + " " + halmet.Name); print("vest.vestStats.Resistence: " + vest.vestStats.Resistence + " " + vest.Name); damage -= damage * halmet.HalmetStats.Resistence; damage -= damage * vest.vestStats.Resistence; print("Taking damage: " + damage); currentHealth -= damage; // If the health is less than zero... if (currentHealth <= 0) { // Set the current health to zero. currentHealth = 0; // Run the Death function since the player has died. Death(); } // Update the Health and Shield status bars. healthBar.UpdateBar(currentHealth, maxHealth); }
public override void Select() { base.Select(); string Name = GetTitle().text; HalmetSettings settings = Data.Instance.GetHalmetSettings(Name); Manager.DescriptionLbl.text = settings.Description; }
public override void Fill(ScriptableObject obj) { HalmetSettings settings = obj as HalmetSettings; GetTitle().text = settings.Name; GetPrice().text = settings.HalmetStats.Price.ToString(); Image img = GetImage(); Debug.Log(settings.Name + " " + (settings.Sprite == null)); img.sprite = settings.Sprite; Manager.DescriptionLbl.text = settings.Description; }
public void AddHalmet(HalmetSettings settings) { AddToArray(ref Halmets, settings); }
void FromJsonToObjects(string json) { string[] objects = json.Split(objSeperators, System.StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < objects.Length; i++) { string[] objectParts = objects[i].Split('|'); string Type = objectParts[0]; string Name = objectParts[1]; string Description = objectParts[2]; string ImgUrl = objectParts[3]; string Object = objectParts[4]; print("Type: " + Type); print("Name: " + Name); print("Description: " + Description); print("ImgUrl: " + ImgUrl); print("objecet: " + Object); //Sprite spriteFromUrl = GetSprite(ImgUrl, value => spriteFromUrl = value); string imagesPath = "ItemsImages/"; switch (Type) { case "Gun": GunStats gunStats = JsonUtility.FromJson <GunStats>(Object); GunSettings gun = ScriptableObject.CreateInstance <GunSettings>(); gun.Fill(gunStats, Name, Description); gun.Sprite = Resources.Load <Sprite>(imagesPath + gun.Name); Data.Instance.AddGun(gun); break; case "Vest": VestStats vestStats = JsonUtility.FromJson <VestStats>(Object); VestSettings vest = ScriptableObject.CreateInstance <VestSettings>(); vest.Fill(Name, Description, vestStats); vest.Sprite = Resources.Load <Sprite>(imagesPath + vest.Name); Data.Instance.AddVest(vest); break; case "Knife": KnifeStats knifeStats = JsonUtility.FromJson <KnifeStats>(Object); KnifeSettings knife = ScriptableObject.CreateInstance <KnifeSettings>(); knife.Fill(knifeStats, Name, Description); knife.Sprite = Resources.Load <Sprite>(imagesPath + knife.Name); Data.Instance.AddKnife(knife); break; case "Grenade": GrenadeStats grenadeStats = JsonUtility.FromJson <GrenadeStats>(Object); GrenadeSettings grenade = ScriptableObject.CreateInstance <GrenadeSettings>(); grenade.Fill(grenadeStats, Name, Description); grenade.Sprite = Resources.Load <Sprite>(imagesPath + grenade.Name); Data.Instance.AddGrenade(grenade); break; case "Halmet": HalmetStats helmetStats = JsonUtility.FromJson <HalmetStats>(Object); HalmetSettings helmet = ScriptableObject.CreateInstance <HalmetSettings>(); helmet.Fill(Name, Description, helmetStats); helmet.Sprite = Resources.Load <Sprite>(imagesPath + helmet.Name); Data.Instance.AddHalmet(helmet); break; default: Debug.Log("Unrecognised item type"); break; } } itemsLoaded = true; }