public void Init(Save.MagicType type, int amount) { this.type = type; this.amount = amount; lightning.gameObject.SetActive(false); fire.gameObject.SetActive(false); air.gameObject.SetActive(false); water.gameObject.SetActive(false); ammoAmount.text = amount.ToString(); ammoAmount.GetComponent <Renderer>().sortingLayerName = "UI"; switch (type) { case Save.MagicType.Fire: fire.gameObject.SetActive(true); break; case Save.MagicType.Lightning: lightning.gameObject.SetActive(true); break; case Save.MagicType.Air: air.gameObject.SetActive(true); break; case Save.MagicType.Water: water.gameObject.SetActive(true); break; } ammoAmount.text = amount.ToString(); }
public void DoMagic() { int selectedType = (int)Save.current.combatData.selectedMagic; if (Save.current.combatData.magic[selectedType].amount > 0) { string attackPath = "error"; switch ((Save.MagicType)selectedType) { case Save.MagicType.Fire: attackPath = "fireAttack"; break; case Save.MagicType.Lightning: attackPath = "lightningAttack"; break; case Save.MagicType.Air: attackPath = "airAttack"; break; case Save.MagicType.Water: attackPath = "waterAttack"; break; default: break; } GameObject magicGO = Instantiate((GameObject)Resources.Load("Attacks/" + attackPath)); MagicAttack magicAttack = magicGO.GetComponent <MagicAttack>(); Vector3 magicPosition = Camera.main.ScreenToWorldPoint(Input.mousePosition); Save.current.combatData.magic[selectedType].amount -= 1; Enemy hoveredEnemy = GetHoveredEnemy(); if (hoveredEnemy != null && hoveredEnemy.currentElementIndex < hoveredEnemy.info.types.Length) { Save.MagicType enemyType = hoveredEnemy.info.types[hoveredEnemy.currentElementIndex]; if (enemyType == (Save.MagicType)selectedType) { hoveredEnemy.TakeDamage(); magicPosition = hoveredEnemy.transform.position; } } magicPosition.z = 0; magicAttack.Init(magicPosition); } Game.instance.uiManager.UpdateMagicUI(); }
public void DropPickup() { int selectedType = Random.Range(1, info.types.Length + 1); if (selectedType > 0) { Save.MagicType type = info.types[Random.Range(0, selectedType)]; GameObject ammoGO = Instantiate((GameObject)Resources.Load("AmmoPickup")); Ammo ammoPickup = ammoGO.GetComponent <Ammo> (); int minAmount = Mathf.Max(selectedType - 2, 3); int maxAmount = Mathf.Max(selectedType + 2, 4); ammoPickup.Init(type, Random.Range(minAmount, maxAmount)); ammoGO.transform.position = transform.position; } if (info.explicitDrop.amount > 0) { GameObject ammoGO = Instantiate((GameObject)Resources.Load("AmmoPickup")); Ammo ammoPickup = ammoGO.GetComponent <Ammo>(); ammoPickup.Init(info.explicitDrop.type, info.explicitDrop.amount); ammoGO.transform.position = transform.position + new Vector3(0.3f, 0.3f, 0); } }
public void AddAmmo(Save.MagicType type, int amount) { Save.current.combatData.magic[(int)type].amount += amount; Game.instance.uiManager.UpdateMagicUI(); }