Ejemplo n.º 1
0
    IEnumerator Restock()
    {
        yield return(new WaitForSeconds(storeRestockTime));

        restockItems();
        Debug.Log("The store has been restocked!");
        _notification.message("The store has been restocked!", 3);
        StartCoroutine(Restock());
    }
Ejemplo n.º 2
0
    void OnMouseUp()
    {
        slot.GetComponent <Image>().sprite = slot_sprite;

        if (!_combatManager.isPaused && _gameManager.current_screen.name == "Combat_screen_UI" && spell_id != 0)
        {
            GameObject.Find("Spell_preview").GetComponent <Spell_preview_script>().closeSpellPreview();

            if (_combatManager.getRound() == battleRound.Player)
            {
                slot.GetComponent <Image>().sprite = slot_sprite_activated;
                if ((spell.resource_cost <= _characterStats.Player_resource))
                {
                    if (spell.type == spell_types.damage && _spellScript.target != null)
                    {
                        spell.Activate(_spellScript.target);
                        _combatManager.changeRound();
                    }
                    else if (spell.type == spell_types.heal || spell.type == spell_types.support)
                    {
                        spell.Activate(_spellScript.target);
                        _combatManager.changeRound();
                    }
                    else
                    {
                        _notification.message("You need a <b>target</b> first!", 3, "red");
                    }

                    //
                    //GameObject.Find("Health_bar").GetComponent<Bar_script>().updateHealth();
                    //GameObject.Find("Resource_bar").GetComponent<Bar_script>().updateResource();
                }
                else
                {
                    _notification.message("You don't have enough energy to use <b>that!", 3, "red");
                }
            }
            else
            {
                _notification.message("it's not your turn!", 3, "red");
            }
        }
    }
Ejemplo n.º 3
0
    public void opponentDie()
    {
        GameObject.Find("Game manager").GetComponent <Spell_script>().setTarget(null);
        gameObject.GetComponent <Visibility_script>().setInvisible();
        _notification.message(enemy_name + " is defeated!", 3);

        if (!_characterStats.isInDefeatedEnemies(id))
        {
            _characterStats.defeated_enemies.Add(id);
        }
    }
    public bool isQuestSlotsFull()
    {
        _characterStats = GameObject.Find("Game manager").GetComponent <Character_stats>();

        for (int i = 0; i < _characterStats.accepted_quests.Length; i++)
        {
            if (_characterStats.accepted_quests[i] == 0)
            {
                return(false);
            }
        }
        _notification.message("You cannot pick up another quest!", 3, "red");
        return(true);
    }
Ejemplo n.º 5
0
    public void checkConfirm()
    {
        _notification = GameObject.Find("Notification").GetComponent <Ingame_notification_script>();

        if (character_name.text.Length >= 1)
        {
            if (isNewCharacter)
            {
                GameObject.Find("Authorization").GetComponent <Authorization_script>().ShowAuthorization("confirmCustomization", 0);
            }
            else
            {
                GameObject.Find("Authorization").GetComponent <Authorization_script>().ShowAuthorization("confirmReCustomization", 0);
            }
        }
        else
        {
            _notification.message("You must choose a name!", 3, "red");
        }
    }
Ejemplo n.º 6
0
    public void initializeBattle(int id)
    {
        _characterStats     = GameObject.Find("Game manager").GetComponent <Character_stats>();
        _characterManager   = GameObject.Find("Character").GetComponent <Character_manager>();
        _notification       = GameObject.Find("Notification").GetComponent <Ingame_notification_script>();
        _enemyManagerScript = GameObject.Find("Game manager").GetComponent <Enemy_manager_script>();
        _itemScript         = GameObject.Find("Game manager").GetComponent <Item_script>();
        _spellScript        = GameObject.Find("Game manager").GetComponent <Spell_script>();
        isPaused            = false;

        _spellScript.actualizeSpells();
        _spellScript.setupAttributes();

        _healthBar        = GameObject.Find("Health_bar").GetComponent <Bar_script>();
        _resourceBar      = GameObject.Find("Resource_bar").GetComponent <Bar_script>();
        _spellbarAnimator = GameObject.Find("Spellbar").GetComponent <Animator>();

        GameObject.Find("Item_preview").GetComponent <Animator>().Play("Item_preview_slide_out_anim");
        GameObject.Find("Inventory slots").GetComponent <Animator>().Play("Inventory_slide_out_anim");
        GameObject.Find("Conversation").GetComponent <Conversation_script>().closeConversation();

        _spellScript.target = null;

        StopAllCoroutines();
        isOngoing = true;

        if (gameObject.GetComponent <Game_manager>().current_screen.name == "Combat_screen_UI")
        {
            if (_characterStats.Player_health > _characterStats.Player_max_health || _characterStats.Player_health < 0)
            {
                _characterStats.Player_health = _characterStats.Player_max_health;
                _healthBar.updateHealth();
            }

            if (_characterStats.Player_resource > _characterStats.Player_max_resource || _characterStats.Player_resource < 0)
            {
                _characterStats.Player_resource = _characterStats.Player_max_resource;
                _resourceBar.updateResource();
            }
        }

        battle_id = id;

        _characterStats.Player_health   = _characterStats.Player_max_health;
        _characterStats.Player_resource = _characterStats.Player_max_resource;

        _healthBar.updateHealth();
        _resourceBar.updateResource();
        GameObject.Find("Spell_preview").GetComponent <Visibility_script>().setInvisible();

        remaining_time.GetComponent <Text_animation>().startAnim((round_time).ToString(), 0.05f);

        opponent_ids = battles[id].opponent_ids;

        opponents[0].GetComponent <Enemy_script>().enemyInitialize(battles[id].opponent_ids[0]);
        opponents[1].GetComponent <Enemy_script>().enemyInitialize(battles[id].opponent_ids[1]);

        generateSequence();


        _notification.message("¤" + battles[id].battle_name, 3);

        battle_background.GetComponent <SpriteRenderer>().sprite = battles[id].background;


        round_counter = 0;
        timer         = 0;
        changeRound();
    }
Ejemplo n.º 7
0
    public void changeRound()
    {
        StopAllCoroutines();
        StartCoroutine("Secs");
        timer = -1;

        if (round_counter != 2)
        {
            round_counter++;
        }
        else
        {
            round_counter = 0;
        }

        if (round[round_counter] == battleRound.Opponent_1 && opponents[0].GetComponent <Enemy_script>().isAlive())
        {
            current_round     = battleRound.Opponent_1;
            currentOpponentID = 0;
            setTurnSign(0);
            round_text.GetComponent <Text_animation>().startAnim(_enemyManagerScript.enemies[battles[battle_id].opponent_ids[0]].enemy_name, 0.05f);
            _notification.message(_enemyManagerScript.enemies[battles[battle_id].opponent_ids[0]].enemy_name + "'s round!", 3);
            _isOpponentAttacked = false;
            StartCoroutine("enemyopponentAttack", 0);
        }
        else if (round[round_counter] == battleRound.Opponent_1 && !opponents[0].GetComponent <Enemy_script>().isAlive())
        {
            changeRound();
        }
        else if (round[round_counter] == battleRound.Opponent_2 && opponents[1].GetComponent <Enemy_script>().isAlive())
        {
            current_round     = battleRound.Opponent_2;
            currentOpponentID = 1;
            setTurnSign(1);

            round_text.GetComponent <Text_animation>().startAnim(_enemyManagerScript.enemies[battles[battle_id].opponent_ids[1]].enemy_name, 0.05f);
            _notification.message(_enemyManagerScript.enemies[battles[battle_id].opponent_ids[1]].enemy_name + "'s round!", 3);
            _isOpponentAttacked = false;
            StartCoroutine("enemyopponentAttack", 1);
        }
        else if (round[round_counter] == battleRound.Opponent_2 && !opponents[1].GetComponent <Enemy_script>().isAlive())
        {
            changeRound();
        }
        else if (round[round_counter] == battleRound.Player)
        {
            current_round = battleRound.Player;

            setTurnSign(2);
            round_text.GetComponent <Text_animation>().startAnim(_characterStats.Player_name, 0.05f);
            _notification.message(_characterStats.Player_name + "'s round!", 3);
        }

        if (!opponents[0].GetComponent <Enemy_script>().isAlive() && !opponents[1].GetComponent <Enemy_script>().isAlive())
        {
            isOngoing = false;
            showResults("Victory");
        }

        spellbarController();
    }
Ejemplo n.º 8
0
    public void showConversation(int id)
    {
        StopCoroutine("Wait");
        gameObject.GetComponent <Animator>().Play("Conversation_slide_in", -1, 0f);
        gameObject.GetComponent <Animator>().Play("Conversation_slide_in");

        GameObject.Find("Overlay").GetComponent <Overlay_script>().showOverlay();


        _charName = _characterStats.Player_name;

        //if (!_characterStats.completed_conversations.Contains(conversations[id]))
        //{
        gameObject.GetComponent <Open_button_script>().Open();

        conversation_id = id;
        dialogue_length = 0;
        string prefix = "";

        switch (conversations[id].type)
        {
        case "normal":
            prefix = "";
            break;

        case "quest":
            prefix = "[Quest]";
            break;

        case "tutorial":
            prefix = "[Tutorial]";
            break;

        default:
            break;
        }
        name_text.GetComponent <Text_animation>().startAnim(conversations[id].speaker[0], 0.01f);
        dialogue_text.GetComponent <Text_animation>().startAnim(conversations[id].dialogue[0], 0.01f);


        var    _option1 = conversations[id].option_1_type[0];
        string _icon1   = "";

        if (_option1.Contains("next"))
        {
            _icon1 = "¤";
        }
        else if (_option1.Contains("exit") || _option1.Contains("finalexit"))
        {
            _icon1 = "×";
        }
        else if (_option1.Contains("skip") || _option1.Contains("change_dialog"))
        {
            _icon1 = "¡";
        }
        else if (_option1.Contains("start_battle"))
        {
            _icon1 = "¿";
        }
        else if (_option1.Contains("quest_add"))
        {
            _icon1 = "£";
        }

        var    _option2 = conversations[id].option_2_type[0];
        string _icon2   = "";

        if (_option2.Contains("next"))
        {
            _icon2 = "¤";
        }
        else if (_option2.Contains("exit") || _option2.Contains("finalexit"))
        {
            _icon2 = "×";
        }
        else if (_option2.Contains("skip") || _option2.Contains("change_dialog"))
        {
            _icon2 = "¡";
        }
        else if (_option2.Contains("start_battle"))
        {
            _icon2 = "¿";
        }
        else if (_option2.Contains("quest_add"))
        {
            _icon2 = "£";
        }

        option_1_button.GetComponent <Text_animation>().startAnim(_icon1 + " " + conversations[id].option_1[0], 0.01f);
        option_2_button.GetComponent <Text_animation>().startAnim(_icon2 + " " + conversations[id].option_2[0], 0.01f);

        checkIfOptionsIsNone();

        _notification.message(prefix + " " + conversations[id].name, 2);
        //}
    }
 public void savePlayer()
 {
     Save_script.savePlayer(this);
     Debug.Log("Player data saved!");
     _notification.message("Player data saved!", 3, "white");
 }