Example #1
0
 void Update()
 {
     if (Input.GetKeyDown(KeyCode.A))
     {
         UIDamageEffect.CreateDamageEffect(transform.position, Random.Range(1, 7));
     }
 }
 public void TakeDamage(int amount, int healthAfter)
 {
     if (amount > 0)
     {
         UIDamageEffect.CreateDamageEffect(transform.position, amount);
         HealthText.text = healthAfter.ToString();
     }
 }
 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));
     }
 }
Example #4
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();
        });
    }