Beispiel #1
0
    /// <summary>
    /// Heals the player, and prints to the Battle Log.
    /// </summary>
    /// <param name="battleLog">Battle Log</param>
    public void Heal(BattleLogController battleLog)
    {
        //setup healing range
        int healAmount = Random.Range(25, 50);

        //if already at max health...
        if (health == maxHealth)
        {
            battleLog.AddText("Already at Max health!");
            return;
        }
        else
        {
            //heal the player
            health = Mathf.Min(health + healAmount, maxHealth);
            //remove a herb
            herbs--;



            //print text
            battleLog.AddText(name + " Uses a Healing Herb, healing them for " + healAmount + "!");
            battleLog.AddText(name + " has " + herbs + " herbs left.");
        }
    }
Beispiel #2
0
 /// <summary>
 /// Adds the item's gold value to the player
 /// </summary>
 /// <param name="playerInst">Player instance.</param>
 /// <param name="enemyInst">Enemy instance.</param>
 public void GrabLoot(Player playerInst, Enemy enemyInst, BattleLogController battleLog)
 {
     //add the item's gold value to the player's
     playerInst.gold += gold;
     //print the message.
     battleLog.AddText("Victory!");
     battleLog.AddText("The " + enemyInst.name + " drops a " + name + ", worth " + gold + " GP.");
 }
Beispiel #3
0
    /// <summary>
    /// Perform Damage Calculation and Print Combat Text to the battle Log.
    /// </summary>
    /// <param name="enemyInst">Enemy Instance</param>
    /// <param name="battleLog">Battle Log</param>
    public void Attack(Enemy enemyInst, BattleLogController battleLog)
    {
        //subtract weapon damage from enemy health (use Mathf.Max to make sure the enemy Health doesn't fall below 0)
        enemyInst.health = Mathf.Max(0, enemyInst.health - damage);
        //Update the UI

        battleLog.AddText(name + " Hits the " + enemyInst.name + " for " + damage + " damage!");
    }
Beispiel #4
0
    /// <summary>
    /// Boosts the player's Maximum health when called.
    /// </summary>
    public void MaxHealthBoost(BattleLogController battleLog)
    {
        //setup HP Boost range
        int hpBoostAmount = Random.Range(5, 20);

        //Boost Max HP
        maxHealth += hpBoostAmount;
        //Print Text
        battleLog.AddText(name + " increases their health by " + hpBoostAmount + " to " + maxHealth + "!");
    }
Beispiel #5
0
    /// <summary>
    /// Increases the player's damage output when called.
    /// </summary>
    public void DamageBoost(BattleLogController battleLog)
    {
        //setup Damage boost range
        int dmgBoostAmount = Random.Range(2, 10);

        //Boost Damage
        damage += dmgBoostAmount;
        //Print Text
        battleLog.AddText(name + " increases their total damage output by " + dmgBoostAmount + " to " + damage + "!");
    }
Beispiel #6
0
    // Use this for initialization
    void Start()
    {
        //Set the Combat state
        openShop.inCombat = true;

        //Set the player's Max Health
        player.maxHealth = player.health;

        //Set the UI Controllers
        UI        = GameObject.Find("UIController").GetComponent <UIController>();
        battleLog = GameObject.Find("BattleLogController").GetComponent <BattleLogController>();
    }
Beispiel #7
0
    public IEnumerator GetBattlesAndRenderLogs()
    {
        battles = new List <Battle>();
        string url   = string.Format("https://backend.josiahkhoo.me/api/battles?character_id={0}", StaticClass.SelectedCharacter.id.ToString());
        string token = string.Format("Token {0}", PlayerPrefs.GetString("token", "").ToString());

        using (var request = UnityWebRequest.Get(url))
        {
            // Debug.Log(url);
            request.SetRequestHeader("Authorization", token);
            yield return(request.SendWebRequest());

            var response = JSON.Parse(request.downloadHandler.text);
            // Debug.Log(response);
            if (request.responseCode == 200)
            {
                var battlesArray = response["battles"];
                for (int i = 0; i < battlesArray.Count; i++)
                {
                    var    battleJson = battlesArray[i];
                    Battle battle     = BattleManager.GetBattleFromString(battleJson.ToString());
                    battles.Add(battle);
                    print(battle.id);
                }
            }
        }
        foreach (Battle thisBattle in battles)
        {
            GameObject          battleLogOption = Instantiate(battleLogPrefab) as GameObject;
            BattleLogController controller      = battleLogOption.GetComponent <BattleLogController>();
            controller.BossName.text = string.Format("Boss: {0}", thisBattle.monster.name.ToString());
            controller.BossTime.text = string.Format("Date: {0}", thisBattle.datetimeCreated.ToShortDateString());
            if (thisBattle.equipment != null)
            {
                controller.drop.text = string.Format("Drop: {0}", thisBattle.equipment.name.ToString());
            }
            else
            {
                controller.drop.text = "";
            }
            if (thisBattle.state == 1)
            {
                controller.state.text = string.Format("Status: Win");
            }
            else
            {
                controller.state.text = string.Format("Status: Failed");
            }
            // sets parent of the character option to the grid
            controller.transform.parent = GridBattleLogsOptions.transform;
        }
    }
Beispiel #8
0
    /// <summary>
    /// Purchases a Herb.
    /// </summary>
    /// <param name="playerInst">Player instance.</param>
    public void BuyHerb(Player playerInst, BattleLogController battleLog, UIController UI)
    {
        //if the player doesn't have enough GP...
        if (playerInst.gold < herbPrice)
        {
            battleLog.AddText("Not enough GP!");
        }
        else
        {
            //pay the cost of the item
            playerInst.gold -= herbPrice;

            //Update the UI
            UI.UpdatePlayerGP(playerInst);

            //give the player the item
            playerInst.herbs++;
            battleLog.AddText(playerInst.name + " now has " + playerInst.herbs + " Healing Herbs.");
        }
    }
Beispiel #9
0
 /// <summary>
 /// Attack the specified player instance.
 /// </summary>
 /// <param name="playerInst">player instance to attack.</param>
 /// <param name="battleLog">The battleLogController (to display text)</param>
 public void Attack(Player playerInst, BattleLogController battleLog)
 {
     //use Mathf.Max to make sure the player's Health doesn't fall below 0
     playerInst.health = Mathf.Max(0, playerInst.health - damage);
     battleLog.AddText(name + " Hits " + playerInst.name + " for " + damage + " damage!");
 }
Beispiel #10
0
 /// <summary>
 /// Prints a message declaring combat has begun to the Debug Log.
 /// </summary>
 public void Encounter(BattleLogController battleLog)
 {
     //Print to the battle Log
     battleLog.AddText("A " + name + " draws near!");
 }
Beispiel #11
0
 /// <summary>
 /// Displays the shop text when called.
 /// </summary>
 /// <param name="playerInst">Player instance.</param>
 public void VisitShop(Player playerInst, BattleLogController battleLog)
 {
     //Shop Text
     battleLog.AddText(playerInst.name + " Enters the Shop.");
 }