public override void Die() { //reset data Freezable f = GetComponent <Freezable>(); if (f != null) { f.Unfreeze(); } SpawnPoint[] spawnPoints = GameObject.FindObjectsOfType <SpawnPoint>(); foreach (SpawnPoint point in spawnPoints) { point.ResetSpawn(); } foreach (PotionSelector.PotionElement potionElement in PotionSelector.GetAllPotionElements()) { potionElement.SetCount(0); } Vector3 checkPointPosition = CheckPointManager.GetCheckPointPos(); transform.position = new Vector3(checkPointPosition.x, checkPointPosition.y, transform.position.z); foreach (SpawnPoint point in spawnPoints) { point.SpawnAll(); } currentHealth = maxHealth; HealthSlider.SetValue(1f); }
public void ApplyInteraction() { int alphakey = input.GetAlphaKey(); if (alphakey >= 1 && alphakey <= 5) { PotionSelector.Set(alphakey - 1); } else { if (input.scrollWheel != 0f) { if (input.scrollWheel > 0f) { PotionSelector.ScrollLeft(); } else { PotionSelector.ScrollRight(); } } } if (input.isInteracting && interactable != null) { interactable.Interact(); } }
public void UseItem() { PotionSelector.PotionElement selected = PotionSelector.GetSelectedPotionElement(); //currentItem ist momentan leer, aber neues, verfuegbares potion ist ausgewaehlt if (currentItem == null && selected.GetCount() > 0) { currentItem = Instantiate(selected.prefab, hand.position, Quaternion.identity, hand).GetComponent <Potion>(); } //currentItem ist vorhanden if (currentItem != null) { //currentItem wurde noch nicht geworfen und es wurde ein neues potion gewaehlt if (!currentItem.HasBeenThrown() && PotionSelector.GetSelectedPotionType() != currentItem.type) { //momentan ausgewaehltes zerstoeren Destroy(currentItem.gameObject); currentItem = null; //falls neues ausgewaehltes verfuegbar, erstellen if (selected.GetCount() > 0) { currentItem = Instantiate(selected.prefab, hand.position, Quaternion.identity, hand).GetComponent <Potion>(); } } //falls mausklick, currentItem vorhanden und momentanes currentItem noch nicht geworfen... if (input.isFiring && currentItem != null && !currentItem.HasBeenThrown()) { ThrowPotion(); //werfen StartCoroutine(RespawnPotionCoroutine(currentItem)); //respawnroutine starten } } }
IEnumerator RespawnPotionCoroutine(Potion thrownPotion) { yield return(new WaitForSeconds(0.2f)); //cooldown PotionSelector.PotionElement selected = PotionSelector.GetSelectedPotionElement(); //wenn currentItem==null ist das potion wahrscheinlich schon geplatzt, ersetzen in UseItem() //wenn currentItem vorhanden if (currentItem != null) { //geworfenen Potion ist noch im flug if (currentItem == thrownPotion) { if (selected.GetCount() > 0) { currentItem = Instantiate(selected.prefab, hand.position, Quaternion.identity, hand).GetComponent <Potion>(); } } } }
void Start() { if (potions.Count == 0) { Debug.LogError("Potion Selector Elements not assigned!"); } mappedPotions = new Hashtable(); //setup foreach (PotionElement potion in potions) { mappedPotions.Add(potion.type, potion); potion.SetEmpty(emptyPotion); potion.SetCount(0); potion.image.transform.localScale = initialScale; } selectedElement = potions[0]; selectedElement.image.transform.localScale = selectedScale; instance = this; }
public static void SubtractFromCountOfPotion(Potion.Type t, int i) { PotionSelector.PotionElement pe = PotionSelector.GetPotionElementOfType(t); pe.SetCount(pe.GetCount() - i); }
public static void AddToCountOfPotion(Potion.Type t, int i) { PotionSelector.PotionElement pe = PotionSelector.GetPotionElementOfType(t); pe.SetCount(pe.GetCount() + i); }
public static void SetCountOfPotion(Potion.Type t, int i) { PotionSelector.GetPotionElementOfType(t).SetCount(i); }
public static int GetPotionAmount(Potion.Type t) { PotionSelector.PotionElement pe = PotionSelector.GetPotionElementOfType(t); return(pe.GetCount()); }
public static Sprite GetPotionSprite(Potion.Type t) { return(PotionSelector.GetPotionElementOfType(t).sprite); }
public static GameObject GetPotionPrefab(Potion.Type t) { return(PotionSelector.GetPotionElementOfType(t).prefab); }