Пример #1
0
        // Start is called before the first frame update
        void Start()
        {
            player       = Player.instance;
            enemyManager = EnemyManager.instance;
            onDeath.AddListener(player.AddMoney);
            onDeath.AddListener(enemyManager.KillEnemy);
            enemyAnim.SetBool("isRunning", true);

            enemyState = EnemyState.PATROL;
            // when the enemy first gets to the player - attack right away
            attackTimer = waitBeforeAttack;
            // memorize the value of chase distance
            currentChaseDistance = chaseDistance;
            dead = false;
        }
Пример #2
0
    public void Awake()
    {
        //if(!Voice)
        //    Voice = GetComponentInChildren<AudioSource>();
        if (Voice)
        {
            VoicePitch = Random.Range(PitchMin, PitchMax);

            if (CharacterRace == Race.Zombie)
            {
                VoicePitch /= 2;
            }

            Voice.pitch = VoicePitch;
        }

        if (!HealtBar)
        {
            HealtBar = GetComponentInChildren <HealtBar>();
        }

        for (int i = 0; i < (int)Equipment.EquipLocations.COUNT; i++)
        {
            Equipped.Add((Equipment.EquipLocations)i, null);
        }


        if (HasEquipment)
        {
            Equip(EquipmentGen.GetRandomEquipment());
        }

        //------------------------- STAT SET-UP --------------------------
        DMG   = new Stat(StatType.DAMAGE, Random.Range(DamMin, DamMax));
        AIM   = new Stat(StatType.AIM, Random.Range(AimMin, AimMax));
        COU   = new Stat(StatType.COURAGE, Random.Range(CouMin, CouMax));
        SPE   = new Stat(StatType.SPEED, Random.Range(SpeMin, SpeMax));
        SMA   = new Stat(StatType.SMARTS, Random.Range(SmaMin, SmaMax));
        Stats = new List <Stat>()
        {
            DMG, AIM, COU, SMA
        }.ToDictionary(s => s.Type);

        //Health is a special case
        HEA    = new Stat(StatType.HEALTH, Random.Range(HeaMin, HeaMax));
        Health = HEA.GetStatMax();

        Material = GetComponentInChildren <Renderer>().material;
        if (Material && Material.HasProperty("_Color"))
        {
            NormalColor = Material.color;
        }
        DamageColor = Color.red;

        OnDamage.AddListener(x => StartCoroutine(HurtRoutine()));
        OnDeath.AddListener(Die);
        OnDeath.AddListener(c => OnAnyCharacterDeath.Invoke(c.CharacterRace));

        AttackRange = transform.lossyScale.x * 2f;

        OnTargetDeath.AddListener(TargetGone);
        OnBeingAttacked.AddListener(BeingAttacked);
        OnCharacterCharacter.AddListener(AttackCharacter);

        if (!navMeshAgent)
        {
            navMeshAgent = GetComponentInChildren <NavMeshAgent>();
        }

        //navMeshAgent.speed = SPE.GetStatMax() /2f; Set in fixedupdate
        Morale = COU.GetStatMax() * 2;

        if (!navMeshAgent)
        {
            Debug.LogWarning(name + ": character does not have Nav Mesh Agent");
        }
    }
Пример #3
0
 public void AddDeathListener(UnityAction listener)
 {
     onDeath.AddListener(listener);
 }
Пример #4
0
 // OnEnable enables the event.
 public static void init()
 {
     death.AddListener(killPlayer);
 }
Пример #5
0
 void Start()
 {
     _onLifeChange.AddListener(LifeChanged);
     _onDeath.AddListener(IsDead);
     m_previousHealth = m_currentHeath;
 }