Пример #1
0
    public void AddDeathEvent(GameObject character, GameObject damager)
    {
        eventCount++;

        if (LayerMask.LayerToName(damager.layer) == "Player")
        {
            EnemyKilled newEvent = new EnemyKilled(damager.transform.position, eventCount, character.name);
            killedList.Add(newEvent);
            Debug.Log(newEvent.GetJson());
        }
        else if (LayerMask.LayerToName(damager.layer) == "Enemy" || LayerMask.LayerToName(damager.layer) == "Collider")
        {
            string enemy = damager.transform.parent?.gameObject.name;
            if (damager.GetComponent <Spit>() != null)
            {
                enemy = "Spitter";
            }

            PlayerDeath newEvent = new PlayerDeath(character.transform.position, eventCount, enemy);
            deathList.Add(newEvent);
            Debug.Log(newEvent.GetJson());
        }
        else if (LayerMask.LayerToName(damager.layer) == "Environment")
        {
            PlayerDeath newEvent = new PlayerDeath(character.transform.position, eventCount, damager.name);
            deathList.Add(newEvent);
            Debug.Log(newEvent.GetJson());
        }
    }