//meant to be overwritten by specific item and still lacks //levels of abstraction. Might need to be redesigned to accomodate //items that Cast() can't public virtual void AffectNPC(NPCEmotions NPC) { NPC.AddPain(strength * painMod); NPC.AddFear(strength * fearMod); NPC.AddJoy(strength * joyMod); NPC.AddLaughter(strength * laughterMod); }
void OnCollisionEnter(Collision col) { NPC = col.gameObject.GetComponent <NPCEmotions> (); strength = Mathf.Abs(Mathf.Max(rb.velocity.x, rb.velocity.y)); audio.volume = (strength / 50); //hits a player if (NPC != null && justHit == false) { audio.clip = soundEffects [0]; audio.Play(); AffectNPC(NPC); justHit = true; } else if (col.transform.tag == "Surface" && justHit == false) //hit something else { audio.clip = soundEffects [1]; audio.Play(); justHit = true; } }
public override void AffectNPC(NPCEmotions NPC) { Debug.Log(strength); NPC.AddPain(strength); NPC.AddFear(strength / 2); NPC.AddJoy(-strength / 2); NPC.AddLaughter(-strength / 2); }
public void SetEmotion(NPCEmotions newEmotion) { emotions = newEmotion; StartCoroutine(ShowEmotion()); }
//keeps from repeatedly hitting void OnCollisionExit(Collision col) { NPC = col.gameObject.GetComponent <NPCEmotions> (); justHit = false; }