コード例 #1
0
 void Update()
 {
     if (Input.GetKeyDown(KeyCode.A))
     {
         UIDamageEffect.CreateDamageEffect(transform.position, Random.Range(1, 7));
     }
 }
コード例 #2
0
 public void TakeDamage(int amount, int healthAfter)
 {
     if (amount > 0)
     {
         UIDamageEffect.CreateDamageEffect(transform.position, amount);
         HealthText.text = healthAfter.ToString();
     }
 }
コード例 #3
0
 public void TakeDamage(int amount, int healthAfter, int healthBefore)
 {
     if (amount > 0)
     {
         float   dirX   = Random.Range(-0.5f, 0.5f);
         float   dirY   = Random.Range(-0.5f, 0.5f);
         Vector3 offset = new Vector3(dirX, dirY, 0);
         UIDamageEffect.CreateDamageEffect(transform.position + offset, amount);
         StartCoroutine(HealthNmberChange(healthAfter, healthBefore));
     }
 }
コード例 #4
0
    /// <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
        //TODO GameObject newDamageEffect = GameObject.Instantiate(GlobalSettings.Instance.DamageEffectPrefab, position, Quaternion.identity) as GameObject;
        GameObject newDamageEffect = GameObject.Instantiate(UIDamageEffectTest.Instance.DamagePrefab, position, Quaternion.identity) as GameObject;
        // Get DamageEffect component in this new game object
        UIDamageEffect de = newDamageEffect.GetComponent <UIDamageEffect>();

        // 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());
    }
コード例 #5
0
    public void AttackTarget(int targetUniqueID, int damageTakenByTarget, int damageTakenByAttacker, int attackerHealthAfter, int targetHealthAfter)
    {
        Debug.Log(targetUniqueID);
        manager.CanAttackNow = false;
        GameObject target = IDHolder.GetGameObjectWithID(targetUniqueID);

        // bring this creature to front sorting-wise.
        w.BringToFront();
        VisualStates tempState = w.VisualState;

        w.VisualState = VisualStates.Transition;

        transform.DOMove(target.transform.position, 0.5f).SetLoops(2, LoopType.Yoyo).SetEase(Ease.InCubic).OnComplete(() =>
        {
            if (damageTakenByTarget > 0)
            {
                UIDamageEffect.CreateDamageEffect(target.transform.position, damageTakenByTarget);
            }
            if (damageTakenByAttacker > 0)
            {
                UIDamageEffect.CreateDamageEffect(transform.position, damageTakenByAttacker);
            }

            if (targetUniqueID == GlobalSettings.Instance.LowPlayer.PlayerID || targetUniqueID == GlobalSettings.Instance.TopPlayer.PlayerID)
            {
                // target is a player
                target.GetComponent <PlayerPortraitVisual>().HealthText.text = targetHealthAfter.ToString();
            }
            else
            {
                target.GetComponent <OneCreatureManager>().HealthText.text = targetHealthAfter.ToString();
            }

            w.SetTableSortingOrder();
            w.VisualState = tempState;

            manager.HealthText.text = attackerHealthAfter.ToString();
            Sequence s = DOTween.Sequence();
            s.AppendInterval(1f);
            s.OnComplete(Command.CommandExecutionComplete);
            //Command.CommandExecutionComplete();
        });
    }