override public void OnUse(GameObject main, GameObject itemTarget) { /////////////////////////////////////// //Local Variables GameObject messageWindow = GameObject.FindWithTag(TagKeys.MESSAGE_WINDOW_KEY); GameObject closestMonster = null; GameObject player; MonsterController monsterController; int closestDistance = int.MaxValue; int monsterDistance; int damage; /////////////////////////////////////// monsterController = GameObject.FindWithTag(TagKeys.MAIN_CONTROLLER_KEY).GetComponent <MonsterController>(); player = GameObject.FindWithTag(TagKeys.PLAYER_KEY); foreach (GameObject monster in monsterController.GetMonsters()) { monsterDistance = NPCMover.DistanceTo(player, monster); if ((monsterDistance <= RANGE) && (monsterDistance < closestDistance)) { closestMonster = monster; closestDistance = monsterDistance; } } if (closestMonster == null) { messageWindow.GetComponent <MessageWindow>().AddText("The scroll does nothing but fizzles!"); } else { damage = Dice.BetweenRange(MIN_DAMAGE, MAX_DAMAGE); messageWindow.GetComponent <MessageWindow>().AddText(String.Format("{0} is shocked for {1} damage!", closestMonster.name, damage)); closestMonster.GetComponent <Fighter>().TakeDamage(damage); } DestroyItem(main); }
public override void OnTarget(GameObject main, GameObject itemTarget) { //////////////////////////////////////////// //Local Variables GameObject messageWindow = GameObject.FindWithTag(TagKeys.MESSAGE_WINDOW_KEY); int damage = 0; //////////////////////////////////////////// damage = Dice.BetweenRange(MIN_DAMAGE, MAX_DAMAGE); itemTarget.GetComponent <Fighter>().TakeDamage(damage); messageWindow.GetComponent <MessageWindow>().AddText(String.Format("{0} was burned for {1} damage!", itemTarget.name, damage.ToString())); DestroyItem(main); }
private static int GetSpawns(int maxSpawns) { ////////////////////////////////////////////////////////// //Local Variables int dungeonLevel = 0; int randomM = 0; int customSpawn = 0; ////////////////////////////////////////////////////////// dungeonLevel = GameObject.FindWithTag(TagKeys.MAIN_CONTROLLER_KEY).GetComponent <MapController>().GetDungeonLevel; randomM = Dice.BetweenRange(1, dungeonLevel); customSpawn = (randomM * dungeonLevel) + maxSpawns; return(customSpawn); }
override public void OnUse(GameObject main, GameObject itemTarget) { /////////////////////////////////////// //Local Variables GameObject messageWindow = GameObject.FindWithTag(TagKeys.MESSAGE_WINDOW_KEY); int HPRestored = 0; /////////////////////////////////////// HPRestored = Dice.BetweenRange(MIN_HEAL, MAX_HEAL); itemTarget.GetComponent <Fighter>().RestoreHP(HPRestored); messageWindow.GetComponent <MessageWindow>().AddText(String.Format("{0} restored {1} HP!", itemTarget.name, HPRestored.ToString())); DestroyItem(main); }
private static int GetBonusHP() { ////////////////////////////////////////////////// //Local Variables const int BONUS_HP_CHANCE = 25; const int MIN = 15; const int MAX = 25; int chanceForHPBonus = 0; int bonus = 0; ////////////////////////////////////////////////// chanceForHPBonus = Dice.D100(); if (chanceForHPBonus <= BONUS_HP_CHANCE) { bonus = Dice.BetweenRange(MIN, MAX); } return(bonus); }
public void LevelUpPower() { /////////////////////////////////////////////////// //Local Variables const int MIN = 1; const int MAX = 3; int bonus = 0; /////////////////////////////////////////////////// if (CanLevelUp() == false) { return; } bonus = Dice.BetweenRange(MIN, MAX); PlayerFighter.Attributes.BasePower += bonus; MessageWindow.GetComponent <MessageWindow>().AddText(String.Format("You gained {0} Power!", bonus)); }