public void AssignTarget(GameObject target, bool trueForCaptain) { stopShooting = gameMaster.battleOver; if (!stopShooting) { myTarget = target.GetComponent <Battle_Unit> (); targetAsGameObj = target; trueIfCaptain = trueForCaptain; // fills bool TRUE if this is a Captain, FALSE if not } }
void ActualShoot(Battle_Unit target) { // The lower the Unit's attack rating, the harder it is to hit at long range distanceToTarget = CalcDistanceToTarget(trueIfCaptain, targetAsGameObj); // this can get passed to the GM // calls on the GameMaster through a bool bool hit = gameMaster.HitCheck(myAttackRating, target.defenseRating, distanceToTarget); if (hit) { DoDamage(target); } }
//this actually DOES the damage void DoDamage(Battle_Unit target) { float damage = CalcDamage(); // apply damage to target target.hitPoints = target.hitPoints - damage; print("I hit " + target.name + " for " + damage); // check if they died if (target.hitPoints <= 0) { targetDead = true; print(target.name + " is dead"); //tell GM to kill target object gameMaster.KillTarget(targetAsGameObj, target.allegiance.ToString()); } }