|
Post by DarkTonic Dev on Jan 28, 2015 1:12:21 GMT
Use a KillableListener Subclass like this (maybe you name it a little better after whatever enemy it's going on). How I have it set up, you get 20 points if an NPC kills this, or 200 if anything else does. The script is pretty short. DeterminingScenario is called by Killable before it uses the World Variable Modifiers of whichever Scenario. So you just need to tell it the name of the Scenario based on whatever logic. The "base" calls aren't strictly necessary because the base class methods of KillableListener don't do anything, but it's a good habit to get into when overriding methods, in case that changes later. You can have as many Scenarios as you want. You just have to write logic to determine which is used. By default only the top one is until you add some code. Attachment shows 2 Scenarios set up, and the KillableListener Subclass goes on the same game object as the Killable so it connects to the Killable automatically. using UnityEngine; using System.Collections;
public class KillableListenerSub : KillableListener { private bool lastHitByNPC = false;
public override void TakingDamage (int pointsDamage, Killable enemyHitBy) { base.TakingDamage(pointsDamage, enemyHitBy); lastHitByNPC = (enemyHitBy.tag == "NPC_Weapon"); }
public override string DeterminingScenario (Killable deadKillable, string scenario) { if (lastHitByNPC) { return "Destroyed_By_NPC"; }
return base.DeterminingScenario (deadKillable, scenario); }
}

|
|