コード例 #1
0
ファイル: MainBattle.cs プロジェクト: JRascagneres/SadHug
 /// <summary>
 /// Updates references and re-setup bars to this next player
 /// </summary>
 public void updateToNewPlayer()
 {
     this.player = manager.Player;
     //Update references
     playerHealthBar.setUpDisplay(player.Health, 100);
     playerMagicBar.setUpDisplay(player.Magic, player.MaximumMagic);
     expBar.setUpDisplay(player.Exp, player.ExpToNextLevel);
 }
コード例 #2
0
ファイル: MainBattle.cs プロジェクト: CyberGW/Daemon
    /// <summary>
    /// Includes finding game objects, setting references and changing background music
    /// [EXTENSION] - Log the player initally being sent into battle
    ///             - Create an original copy of all the player stats to be restored to revert stat changes
    /// </summary>
    void Start()
    {
        //Find Objects
        attacksPanel = GameObject.Find("BattleCanvas").transform.Find("AttacksPanel").gameObject;
        playerStats  = GameObject.Find("PlayerStats");
        enemyStats   = GameObject.Find("EnemyStats");
        attackButton = GameObject.Find("AttackButton").GetComponent <Button> ();
        playerButton = GameObject.Find("PlayersButton").GetComponent <Button> ();
        runButton    = GameObject.Find("RunButton").GetComponent <Button> ();
        setButtonsInteractable(true);
        textBox      = GameObject.Find("TextBox").transform.Find("Text").GetComponent <Text> ();
        playerSprite = GameObject.Find("PlayerImage").GetComponent <Image> ();
        enemySprite  = GameObject.Find("EnemyImage").GetComponent <Image> ();


        //Setup Object references
        playerArray = PlayerData.instance.data.Players;
        enemyObject = GlobalFunctions.instance.getEnemy();
        moneyReward = GlobalFunctions.instance.getMoney();
        itemReward  = GlobalFunctions.instance.getItem();

        //create a copy of player stats before battle
        originalCopy = createOriginalCopy(playerArray);
        manager      = new BattleManager(playerArray[0], enemyObject, moneyReward);
        player       = manager.Player;
        enemy        = manager.Enemy;
        Texture2D image;

        image = enemy.Image;
        enemySprite.sprite = Sprite.Create(image, new Rect(0.0f, 0.0f, image.width, image.height), new Vector2(0.5f, 0.5f));
        image = player.Image;
        playerSprite.sprite = Sprite.Create(image, new Rect(0.0f, 0.0f, image.width, image.height), new Vector2(0.5f, 0.5f));

        //Log player being used
        QManagerObj.manager.logQuestVariable(questTypes.onlyOneCharacter, player.Name);

        //setup references and inital displays of all bars
        expBar          = playerStats.transform.Find("Exp").GetComponent <StatsScript> ();
        playerHealthBar = playerStats.transform.Find("Health").GetComponent <StatsScript> ();
        playerMagicBar  = playerStats.transform.Find("Magic").GetComponent <StatsScript> ();
        enemyHealthBar  = enemyStats.transform.Find("Health").GetComponent <StatsScript> ();
        enemyMagicBar   = enemyStats.transform.Find("Magic").GetComponent <StatsScript> ();
        expBar.setUpDisplay(player.Exp, player.ExpToNextLevel);
        playerHealthBar.setUpDisplay(player.Health, 100);
        enemyHealthBar.setUpDisplay(enemy.Health, 100);
        playerMagicBar.setUpDisplay(player.Magic, player.MaximumMagic);
        enemyMagicBar.setUpDisplay(enemy.Magic, enemy.MaximumMagic);
        //Setup local variables
        moveChosen = false;
        playerDied = false;

        //Change Music
        BGM = Resources.Load("Audio/battle", typeof(AudioClip)) as AudioClip;
        SoundManager.instance.playBGM(BGM);
        victory = Resources.Load("Audio/victory", typeof(AudioClip)) as AudioClip;
    }
コード例 #3
0
ファイル: MainBattle.cs プロジェクト: JRascagneres/SadHug
    /// <summary>
    /// Updates the saved and displayed exp
    /// </summary>
    /// <returns>Coroutine function to update exp bar</returns>
    /// <param name="totalExp">The total exp the player has gained</param>
    private IEnumerator updateExp(int totalExp)
    {
        yield return(new WaitForSeconds(1f));

        int gainedExp;
        int remainingExp = totalExp;

        while ((player.Exp + remainingExp) >= player.ExpToNextLevel)
        {
            gainedExp     = player.ExpToNextLevel - player.Exp;
            remainingExp -= gainedExp;
            yield return(StartCoroutine(updateExpHelper(gainedExp, true)));

            expBar.setUpDisplay(0, player.ExpToNextLevel);
        }
        if (remainingExp > 0)
        {
            gainedExp = player.Exp + remainingExp;
            yield return(StartCoroutine(updateExpHelper(gainedExp, false)));
        }
    }
コード例 #4
0
ファイル: MainBattle.cs プロジェクト: CyberGW/Daemon
 /// <summary>
 /// Updates references and re-setup bars to this next player
 /// </summary>
 public void updateToNewPlayer()
 {
     this.player = manager.Player;
     Debug.Log(player.Name);
     //Update references
     playerHealthBar.setUpDisplay(player.Health, 100);
     playerMagicBar.setUpDisplay(player.Magic, player.MaximumMagic);
     //update sprite shown
     playerSprite.sprite = Sprite.Create(player.Image, new Rect(0.0f, 0.0f, player.Image.width, player.Image.height),
                                         new Vector2(0.5f, 0.5f));
     Debug.Log(player.ExpToNextLevel);
     expBar.setUpDisplay(player.Exp, player.ExpToNextLevel);
 }