/// <summary> /// Creates the damage effect. /// This is a static method, so it should be called like this: DamageEffect.CreateDamageEffect(transform.position, 5); /// </summary> /// <param name="position">Position.</param> /// <param name="amount">Amount.</param> public static void CreateDamageEffect(Vector3 position, int amount) { if (amount == 0) { return; } // Instantiate a DamageEffect from prefab GameObject newDamageEffect = new GameObject(); newDamageEffect = GameObject.Instantiate(DamageEffectTest.Instance.DamagePrefab, position, Quaternion.identity) as GameObject; // Get DamageEffect component in this new game object DamageEffect de = newDamageEffect.GetComponent <DamageEffect>(); // Change the amount text to reflect the amount of damage dealt if (amount < 0) { // NEGATIVE DAMAGE = HEALING de.AmountText.text = "+" + (-amount).ToString(); de.DamageImage.color = Color.green; } else { de.AmountText.text = "-" + amount.ToString(); } // start a coroutine to fade away and delete this effect after a certain time de.StartCoroutine(de.ShowDamageEffect()); }
/// <summary> /// Creates the damage effect. /// Muestra el daño a la criatura o jugador. /// </summary> /// <param name="position">Position.</param> /// <param name="amount">Amount.</param> public static void CreateDamageEffect(Vector3 position, int health, int amount) { GameObject newDamageEffect = InstanciarPrefab(position); // Get DamageEffect component in this new game object DamageEffect de = newDamageEffect.GetComponent <DamageEffect>(); // Change the amount text to reflect the amount of damage dealt ConfiguracionUsuario settings = ConfiguracionUsuario.Instance; if (settings.ConfiguracionBatalla.Equals(ConfiguracionUsuario.TIPO_CONFIGURACION.ENTERO)) { de.AmountText.text = "-" + amount.ToString(); } //de.AmountText.text = health.ToString()+"-"+amount.ToString(); else if (settings.ConfiguracionBatalla.Equals(ConfiguracionUsuario.TIPO_CONFIGURACION.FRACCION)) { de.AmountText.text = "-" + ConfiguracionUsuario.ObtenerFraccion(amount, health) + "x" + health.ToString(); } else { de.AmountText.text = "-" + ConfiguracionUsuario.ObtenerPorcentaje(amount, health); } //de.AmountText.text = health.ToString()+"-"+Settings.ObtenerFraccion(amount,health)+"x"+health.ToString(); // start a coroutine to fade away and delete this effect after a certain time de.StartCoroutine(de.ShowDamageEffect()); //Comandas.Instance.CompletarEjecucionComanda(); }
public static void CreateDamageEffect(Vector3 position, int amount) { GameObject newDamageEffect = GameObject.Instantiate(GlobalSettings.Instance.DamageEffectPrefab, position, Quaternion.identity) as GameObject; DamageEffect DE = newDamageEffect.GetComponent <DamageEffect>(); DE.DamageText.text = "-" + amount.ToString(); DE.StartCoroutine(DE.ShowDamageEffect()); }
public static void CreateDamageEffect(Vector3 position, int amount) { // Instantiate a DamageEffect from prefab GameObject newDamageEffect = GameObject.Instantiate(GameStateSync.Instance.DamageEffectPrefab, position, Quaternion.identity) as GameObject; // Get DamageEffect component in this new game object DamageEffect de = newDamageEffect.GetComponent <DamageEffect>(); // Change the amount text to reflect the amount of damage dealt de.AmountText.text = "-" + amount.ToString(); // start a coroutine to fade away and delete this effect after a certain time de.StartCoroutine(de.ShowDamageEffect()); }
public static void CreateDamageEffect(Vector3 position) { GameObject newDamageEffect = InstanciarPrefab(position); // Get DamageEffect component in this new game object DamageEffect de = newDamageEffect.GetComponent <DamageEffect>(); // Change the amount text to reflect the amount of damage dealt de.AmountText.text = ""; // start a coroutine to fade away and delete this effect after a certain time de.StartCoroutine(de.ShowDamageEffect()); //Comandas.Instance.CompletarEjecucionComanda(); }
public static void CreateDamageEffect(Vector3 position, int amount) { // wywołaj preefab DamageEffect GameObject newDamageEffect = new GameObject(); // DO_ZROBIENIA GameObject.Instantiate(GlobalSettings.Instance.DamageEffectPrefab, position, Quaternion.identity) as GameObject; newDamageEffect = GameObject.Instantiate(DamageEffectTest.Instance.DamagePrefab, position, Quaternion.identity) as GameObject; // Uzyskaj składnik DamageEffect w tym nowym obiekcie gry DamageEffect de = newDamageEffect.GetComponent <DamageEffect>(); // Zmień tekst, aby odzwierciedlić ilość zadawanych obrażeń de.AmountText.text = "-" + amount.ToString(); // uruchom ShowDamageEffect() de.StartCoroutine(de.ShowDamageEffect()); }
/// <summary> /// Creates the damage effect. /// This is a static method, so it should be called like this: DamageEffect.CreateDamageEffect(transform.position, 5); /// </summary> /// <param name="position">Position.</param> /// <param name="amount">Amount.</param> public static void CreateDamageEffect(Vector3 position, int amount) { // Instantiate a DamageEffect from prefab GameObject newDamageEffect = new GameObject(); // TODO = GameObject.Instantiate(GlobalSettings.Instance.DamageEffectPrefab, position, Quaternion.identity) as GameObject; newDamageEffect = GameObject.Instantiate(GameManager.instance.DamageEffectPrefab, position, Quaternion.identity, ScreenManager.instance.GetCurrentMainCanvas().transform) as GameObject; newDamageEffect.transform.localPosition = new Vector3(0, 0, 0); // Get DamageEffect component in this new game object DamageEffect de = newDamageEffect.GetComponent <DamageEffect>(); // Change the amount text to reflect the amount of damage dealt de.AmountText.text = "-" + amount.ToString(); // start a coroutine to fade away and delete this effect after a certain time de.StartCoroutine(de.ShowDamageEffect()); }
/// <summary> /// Creates the damage effect. /// This is a static method, so it should be called like this: DamageEffect.CreateDamageEffect(transform.position, 5); /// </summary> /// <param name="position">Position</param> /// <param name="amount">Amount of damage</param> public static void CreateDamageEffect(Vector3 position, int amount) { if (amount == 0) { return; } GameObject newDamageEffect = GameObject.Instantiate(GlobalSettings.Instance.DamageEffectPrefab, position, Quaternion.identity) as GameObject; DamageEffect de = newDamageEffect.GetComponent <DamageEffect>(); if (amount < 0) { de.AmountText.text = "+" + (-amount).ToString(); de.AmountText.color = Color.green; } else { de.AmountText.text = "-" + amount.ToString(); } de.StartCoroutine(de.ShowDamageEffect()); }
/// <summary> /// Creates the damage effect. /// This is a static method, so it should be called like this: DamageEffect.CreateDamageEffect(transform.position, 5); /// </summary> /// <param name="position">Position.</param> /// <param name="amount">Amount.</param> public static void CreateDamageEffect(Vector3 position, int amount) { // TRYING OUT THIS NEW CODE, IF IT BREAKS SHIT - USE COMMENTED CODE BELOW // if (amount == 0) { return; } // Instantiate a DamageEffect prefab GameObject newDamageEffect = GameObject.Instantiate(GlobalSettings.Instance.DamageEffectPrefab, position, Quaternion.identity) as GameObject; // Get DamageEffect component in this new gameobject DamageEffect de = newDamageEffect.GetComponent <DamageEffect>(); // Change the amount text to reflect the amount of damage delt if (amount < 0) { // NEGATIVE DAMAGE CAN WORK AS 'HEALING' de.AmountText.text = "+" + (-amount).ToString(); de.DamageImage.color = Color.green; } else { de.AmountText.text = "-" + amount.ToString(); } // Start a coroutine to fade away and delete this effect after a certain time de.StartCoroutine(de.ShowDamageEffect()); // OLD CODE // // // Instantiate a DamageEffect from prefab // GameObject newDamageEffect = GameObject.Instantiate(GlobalSettings.Instance.DamageEffectPrefab, position, Quaternion.identity) as GameObject; // //newDamageEffect = GameObject.Instantiate(DamageEffectTest.Instance.DamagePrefab, position, Quaternion.identity) as GameObject; // // Get DamageEffect component in this new game object // DamageEffect de = newDamageEffect.GetComponent<DamageEffect>(); // // Change the amount text to reflect the amount of damage dealt // de.AmountText.text = "-"+amount.ToString(); // // start a coroutine to fade away and delete this effect after a certain time // de.StartCoroutine(de.ShowDamageEffect()); }
/// <summary> /// Creates the damage effect. /// This is a static method, so it should be called like this: DamageEffect.CreateDamageEffect(transform.position, 5); /// </summary> /// <param name="position">Position.</param> /// <param name="amount">Amount.</param> public static void CreateStatsEffect(Vector3 position, int attackAmount, int healthAmount) { if (attackAmount == 0 && healthAmount == 0) { return; } // Instantiate a DamageEffect from prefab GameObject newStatsEffect = GameObject.Instantiate(GlobalSettings.Instance.DamageEffectPrefab, position, Quaternion.identity) as GameObject; // Get DamageEffect component in this new game object DamageEffect se = newStatsEffect.GetComponent <DamageEffect>(); // Change the amount text to reflect the amount of damage dealt string attackAmountText = ""; string healthAmountText = ""; if (attackAmount >= 0) { attackAmountText = "+" + attackAmount.ToString(); } else { attackAmountText = "-" + (-attackAmount).ToString(); } if (healthAmount >= 0) { healthAmountText = "+" + healthAmount.ToString(); } else { healthAmountText = "-" + (-healthAmount).ToString(); } se.AmountText.text = attackAmountText + "/" + healthAmountText; // start a coroutine to fade away and delete this effect after a certain time se.DamageImage.color = Color.blue; se.StartCoroutine(se.ShowDamageEffect()); }
public static void CreateDamageEffect(GameObject go, int amount) { GameManager gm = GameManager.Instance; GameObject newDamageEffect = Instantiate(gm.DamagePrefab); DamageEffect de = newDamageEffect.GetComponent <DamageEffect>(); newDamageEffect.transform.SetParent(go.transform, false); newDamageEffect.transform.position = go.transform.position; newDamageEffect.transform.DOLocalRotateQuaternion(newDamageEffect.transform.localRotation * Quaternion.Euler(0, 0, GameManager.Instance.camera.transform.localRotation.eulerAngles.y), 0f); newDamageEffect.transform.localScale = new Vector3(-0.43f, 0.5f, 1); // Instantiate a DamageEffect from prefab // Get DamageEffect component in this new game object if (amount < 0) { de.AmountText.color = Color.green; de.AmountText.text = "+" + Math.Abs(amount).ToString(); } else if (amount > 0) { de.AmountText.color = Color.blue; de.AmountText.text = "-" + (amount).ToString(); } // start a coroutine to fade away and delete this effect after a certain time de.StartCoroutine(de.ShowDamageEffect(amount)); }