public void Visit(Knight hit, InfoCollision info)
        {
            var armor = hit.Armor;

            armor            -= info.Damage;
            hit.Health       -= armor;
            hit.TextMesh.text = hit.Health.ToString();
        }
Beispiel #2
0
        public override void CollisionEnter(InfoCollision info)
        {
            base.CollisionEnter(info);
            if (info.Type != AmmunitionType.ArmorPiercingBullet)
            {
                Hp += _reduceDamage;
            }

            _isDead = true;
        }
Beispiel #3
0
    public void SetDamage(InfoCollision info)
    {
        Debug.Log("Урон");
        if (_projector == null)
        {
            return;
        }
        var projectorRotation = Quaternion.FromToRotation(-Vector3.forward, info.Hit.normal);
        var obj = Instantiate(_projector, info.Hit.point + info.Hit.normal * 0.25f, projectorRotation, info.ObjCollision);         // manager

        obj.transform.rotation = Quaternion.Euler(obj.transform.eulerAngles.x, obj.transform.eulerAngles.y, Random.Range(0, 360));
    }
Beispiel #4
0
        [SerializeField] private BulletProjector _projector; //todo manager

        #endregion


        #region ICollision

        public virtual void OnCollision(InfoCollision info)
        {
            if (_projector == null)
            {
                return;
            }
            var projectorRotation = Quaternion.FromToRotation(-Vector3.forward, info.Contact.normal);
            var obj = Instantiate(_projector, info.Contact.point + info.Contact.normal * 0.25f,
                                  projectorRotation, info.ObjCollision); //todo manager

            obj.transform.rotation = Quaternion.Euler(obj.transform.eulerAngles.x, obj.transform.eulerAngles.y,
                                                      Random.Range(0, 360));
        }
Beispiel #5
0
        public void Visit(Hit hit, InfoCollision info)
        {
            if (hit is Knight knight)
            {
                var armor = knight.Armor;

                armor            -= info.Damage;
                hit.Health       -= armor;
                hit.TextMesh.text = hit.Health.ToString();
            }
            if (hit is Enemy)
            {
                hit.Health       -= info.Damage;
                hit.TextMesh.text = hit.Health.ToString();
            }
            if (hit is Enviroment)
            {
            }
        }
Beispiel #6
0
    public void Damage(InfoCollision info)
    {
        if (_HP > 0)
        {
            _HP -= info.Damage / _healthDivider;
            _hpBar.fillAmount = _HP / 100;
            _hpText.text      = _HP.ToString();

            if (_HP <= 0)
            {
                Revive();
            }
            Debug.Log("Игрок получил урон");
        }
        else
        {
            Revive();
        }
    }
Beispiel #7
0
        //todo дописать поглащение урона
        public void OnCollision(InfoCollision info)
        {
            if (_isDead)
            {
                return;
            }
            if (Hp > 0)
            {
                Hp -= info.Damage;
            }

            if (Hp <= 0)
            {
                if (!TryGetComponent <Rigidbody>(out _))
                {
                    gameObject.AddComponent <Rigidbody>();
                }

                Destroy(gameObject, 10);

                OnPointChange?.Invoke();
                _isDead = true;
            }
        }
Beispiel #8
0
        public void OnCollision(InfoCollision info)
        {
            if (Hp > 0)
            {
                Hp -= info.Damage;
            }

            if (Hp <= 0)
            {
                foreach (var child in GetComponentsInChildren <Transform>())
                {
                    child.parent = null;

                    var tempRbChild = child.GetComponent <Rigidbody>();
                    if (!tempRbChild)
                    {
                        tempRbChild = child.gameObject.AddComponent <Rigidbody>();
                    }
                    Destroy(child.gameObject, 10);
                }

                OnDieChange?.Invoke(this);
            }
        }
Beispiel #9
0
        public void Bang(InfoCollision collision)
        {
            if (_isCharacterController)
            {
                _cashCharacterController.enabled = false;
            }
            if (_isNavMeshAgent)
            {
                _cashNavMeshAgent.enabled = false;
            }
            if (_isKinematicRigidBody)
            {
                Rigidbody.isKinematic = !_cashKinematicRigidBody;
            }

            Rigidbody.AddForce(collision.Direction, ForceMode.Impulse);

            var tempObj = GetComponent <ICollision>();

            if (tempObj != null)
            {
                tempObj.OnCollision(collision);
            }
        }
Beispiel #10
0
 public void OnCollision(InfoCollision info)
 {
     OnApplyDamageChange?.Invoke(info);
 }
 public void Visit(Enemy hit, InfoCollision info)
 {
     hit.Health       -= info.Damage;
     hit.TextMesh.text = hit.Health.ToString();
 }
 public void Visit(Environment hit, InfoCollision info)
 {
 }
Beispiel #13
0
 public void OnCollision(InfoCollision info)
 {
     Debug.Log($"HeadBot.OnCollision.Info:{info.Damage}");
     OnApplyDamageChange?.Invoke(new InfoCollision(info.Damage * 500,
                                                   info.Contact, info.ObjCollision, info.Direction));
 }
Beispiel #14
0
 public void OnCollision(InfoCollision info)
 {
     OnApplyDamageChange?.Invoke(new InfoCollision(info.Damage * 500,
                                                   info.Contact, info.ObjCollision, info.Dir));
 }
Beispiel #15
0
 public void OnCollision(InfoCollision info)
 {
     Debug.Log($"BodyBot.OnCollision.Info:{info.Damage}");
     OnApplyDamageChange?.Invoke(info);
 }