// Message methods /// <summary> /// Handles the OnAttacked message /// </summary> /// <param name="attacker">The BaseFighter that attacked this GameObject</param> void OnAttacked(object attacker) { // Make attacker a BaseFighter reference BaseFighter attackerBF = attacker as BaseFighter; // Sanity check: attacker should be a BaseFighter if (attackerBF == null) { return; } // Grab the damage value int attack = attackerBF.AttackStr; // Instantiate a new DamageText with attack GameObject newDamText = Instantiate(DTPreFab) as GameObject; Canvas can = FindObjectOfType <Canvas> (); newDamText.transform.SetParent(can.transform, false); DamageText newText = newDamText.GetComponent <DamageText> (); newText.Damage = attack; // Set Damage newText.ChangePosition(gameObject); }