예제 #1
0
        private void OnCollisionEnter(Collision other)
        {
            if (other.gameObject.layer == LayerMask.NameToLayer(R.S.Layer.Player) || other.gameObject.layer == LayerMask.NameToLayer(R.S.Layer.Ai))
            {
                bool   isAI   = false;
                Health health = other.gameObject.GetComponentInChildren <Health>();

                IInventory inventoryController = other.gameObject.GetComponentInChildren <PlayerController>();
                if (inventoryController == null)
                {
                    inventoryController = other.gameObject.GetComponentInChildren <ActorAI>();
                    isAI = true;
                }
                if (health != null)
                {
                    Item[] protectionItems  = inventoryController.GetProtections();
                    float  helmetProtection = protectionItems[0] == null ? 0 : ((Helmet)protectionItems[0]).ProtectionValue;
                    float  vestProtection   = protectionItems[1] == null ? 0 : ((Vest)protectionItems[1]).ProtectionValue;
                    health.Hit(Dommage - (Dommage * ((helmetProtection + vestProtection) / 100)), isAI);
                    if (health.HealthPoints <= 0 + Dommage - (Dommage * ((helmetProtection + vestProtection) / 100)))
                    {
                        PlayerController playerController = playerWhoShot.gameObject.GetComponent <PlayerController>();
                        if (playerController != null)
                        {
                            playerController.AddKillToDatabse(isAI);
                        }
                    }
                }
            }
            Destroy(gameObject);
        }
예제 #2
0
        private void OnDeathCircleFixedUpdate(DeathCircleStatusUpdateEvent deathCircleStatusUpdateEvent)
        {
            Brain.UpdateDeathCircleKnowledge(deathCircleStatusUpdateEvent.DeathCircleController);
            Vector3 aiPosition          = Vector3.zero;
            Vector3 deathCirclePosition = Vector3.zero;

            aiPosition.x          = this.transform.position.x;
            aiPosition.y          = AIController.FloorYOffset;
            aiPosition.z          = this.transform.position.z;
            deathCirclePosition.x = Brain.DeathCircleCenterPosition.x;
            deathCirclePosition.y = AIController.FloorYOffset;
            deathCirclePosition.z = Brain.DeathCircleCenterPosition.z;
            if (Vector3.Distance(aiPosition, deathCirclePosition) > Brain.DeathCircleRadius)
            {
                health.Hit(Brain.CurrentDeathCircleHurtPoints * Time.deltaTime, true);
                Brain.InjuredByDeathCircle = true;
            }
        }
예제 #3
0
 private void OnPlayerOutDeathCircle(DeathCircleHurtEvent deathCircleHurtEvent)
 {
     health.Hit(deathCircleHurtEvent.HurtPoints, false);
 }