/// <summary> /// Called before game start /// </summary> private void Awake() { ItemPickupEvent = new ItemEvent(); ItemPickupEvent.AddListener(Ping); ItemDroppedEvent = new ItemEvent(); ItemDroppedEvent.AddListener(Ping); DialogOpenEvent = new DialogEvent(); DialogOpenEvent.AddListener(Ping); DialogOptionSelectedEvent = new DialogOptionEvent(); DialogOptionSelectedEvent.AddListener(Ping); CharacterDeathEvent = new CharacterEvent(); CharacterDeathEvent.AddListener(Ping); InteractableActivatedEvent = new InteractableEvent(); }
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"); } }