private void SpawnCombatNumber(string value, CombatMessageType type)
    {
        GameObject combatNumberObj = ObjectPoolController.Instance.Spawn(_combatNumber.gameObject, Vector3.zero, Quaternion.identity);

        _manager.AddToGameplayUI(combatNumberObj.transform);
        var   combatNumberLogic = combatNumberObj.GetComponent <CombatFlyingTextLogic>();
        float clipLength        = combatNumberLogic.Initialize(value, transform, type, _combatNumberDirectionToggle);

        _combatNumberDirectionToggle = !_combatNumberDirectionToggle;
        ObjectPoolController.Instance.RecycleAfter(combatNumberObj, clipLength);
    }
    public float Initialize(string value, Transform target, CombatMessageType type, bool toTheRight)
    {
        if (_animNames.Count == 0)
        {
            foreach (AnimationState a in _animation)
            {
                _animNames.Add(a.name);
            }
        }

        if (_animation.GetClipCount() != 3 || _animNames.Count != 3)
        {
            Debug.LogError("CombatFlyingText must have 3 anims!!");
            return(0.0f);
        }

        _targetTransform = target;
        UpdatePosition();

        _icon.gameObject.SetActive(false);
        _valueTxt.text  = value;
        _valueTxt.color = _messageColorConfig[(int)type].MessageColor;
        int animIdx = -1;

        switch (type)
        {
        case CombatMessageType.Healing:
            animIdx = 2;
            _icon.gameObject.SetActive(true);
            _icon.sprite = _messageColorConfig[(int)type].Icon;
            break;

        case CombatMessageType.Normal:
        case CombatMessageType.Lethal:
        case CombatMessageType.CritHit:
            transform.position += new Vector3(Random.Range(-_randomPositionOffset.x, _randomPositionOffset.x),
                                              Random.Range(-_randomPositionOffset.y, _randomPositionOffset.y),
                                              0.0f);
            animIdx = toTheRight ? 0 : 1;
            break;
        }

        _animation.Play(_animNames[animIdx]);

        return(_animation.GetClip(_animNames[animIdx]).length);
    }
Example #3
0
    private void SpawnCombatNumber(string value, CombatMessageType type)
    {
        GameObject combatNumberObj = ObjectPoolController.Instance.Spawn(_combatFloatingTextPrefab, Vector3.zero, Quaternion.identity);

        _spawnedCombatFloatingTextGameObjectList.Add(combatNumberObj);
        var   combatNumberLogic = combatNumberObj.GetComponent <CombatFlyingTextLogic>();
        float clipLength        = combatNumberLogic.Initialize(value, transform, type, _combatHealthNumberToTheRight);

        _combatHealthAngle            = ComputeNewAngle();
        _combatHealthNumberToTheRight = !_combatHealthNumberToTheRight;
        if (ObjectPoolController.Instance.IsSpawned(combatNumberObj))
        {
            ObjectPoolController.Instance.RecycleAfter(combatNumberObj, clipLength);
            return;
        }
        ;
    }
Example #4
0
    public bool TakeDamage(Vector3 from, int damage)
    {
        if (!IsAlive())
        {
            return(false);
        }

        if (_invincible)
        {
            Debug.Log("Entity is invincible!");
            return(true);
        }

        bool itWasAlive       = _currentDamage > 0;
        bool isDead           = false;
        int  calculatedDamage = CalculateDamage(damage);

        _currentDamage -= calculatedDamage;
        _lifeBarController.UpdateValue(_currentDamage, _data.MaxLife);
        CameraShakeType   shakeType  = _hurtCameraShakeType;
        CombatMessageType damageType = CombatMessageType.Normal;

        Vector3 damageForward = transform.position - from;

        if (itWasAlive)
        {
            isDead = _currentDamage <= 0;
            //TriggerEffect(damageForward.normalized, isDead, from);
            if (isDead)
            {
                _data.OnDeath?.Invoke(damageForward);
                damageType = CombatMessageType.Lethal;
                shakeType  = _deathCameraShakeType;
            }
            else
            {
                _data.OnDamage?.Invoke(damageForward);
            }
        }

        SpawnCombatNumber(calculatedDamage.ToString(), damageType);
        _data.CameraShake.GenerateImpulse(shakeType);
        return(!isDead);
    }
        private void UpdateCombatMessageTypeValue()
        {
            if (config.GetValue <int>("CombatMessagesType", out int value))
            {
                combatMessageType = (CombatMessageType)value;
                radioButtonMessagesBrief.Checked   = combatMessageType == CombatMessageType.BRIEF;
                radioButtonMessagesVerbose.Checked = combatMessageType == CombatMessageType.VERBOSE;
            }
            else if (radioButtonMessagesBrief.Checked)
            {
                combatMessageType = CombatMessageType.BRIEF;
            }
            else
            {
                combatMessageType = CombatMessageType.VERBOSE;
            }

            SetValue("CombatMessagesType", (int)combatMessageType);
        }