Exemple #1
0
    public override void OnComplete()
    {
        GameManager.Instance.ui_ticker.Write(GameText.GetText("ACHIEVE/COMPLETE", name));

        if (metas.Count >= step + 1)
        {
            Meta meta = metas[step];
            name  = meta.name;
            step  = meta.step;
            count = count - goal;
            goal  = meta.goal;
            Database.Execute(Database.Type.UserData,
                             "UPDATE user_achieve SET achieve_name='" + name + "', achieve_step=" + step + ", achieve_count=" + count + ", achieve_goal=" + goal + " WHERE achieve_type='" + type + "'"
                             );

            GameManager.Instance.ui_textbox.AsyncWrite(GameText.GetText("ACHIEVE/COMPLETE", name) + "\n" + reward_stat.ToString());
            if (count >= goal)
            {
                OnComplete();
            }
        }
        else
        {
            ProgressManager.Instance.Remove(this);
        }
    }
Exemple #2
0
    private void InitDungeon()
    {
        StartCoroutine(GameManager.Instance.CameraFade(Color.black, new Color(0.0f, 0.0f, 0.0f, 0.0f), 1.5f));

        dungeon.Init(++dungeon_level);
        mini_map.Init(dungeon);

        dungeon.InitRooms();
        mini_map.CurrentPosition(dungeon.data.current_room.id);

        ProgressManager.Instance.Update(ProgressType.DungeonLevel, "", dungeon.level);
        StartCoroutine(GameManager.Instance.ui_textbox.Write(GameText.GetText("DUNGEON/WELCOME", dungeon.level), false));
    }
Exemple #3
0
    public IEnumerator Open()
    {
        if (Inventory.MAX_SLOT_COUNT <= GameManager.Instance.player.inventory.count)
        {
            yield return(GameManager.Instance.ui_textbox.Write(GameText.GetText("ERROR/INVENTORY_FULL"), false));

            yield break;
        }

        touch_input.touch_collider.enabled = false;
        lock_icon.gameObject.SetActive(false);
        AudioManager.Instance.Play(AudioManager.BOX_OPEN);
        StartCoroutine(Util.UITween.Overlap(close, open, time));

        Item item = room.item.CreateInstance();

        GameManager.Instance.player.inventory.Add(item);
        yield return(GameManager.Instance.ui_textbox.Write(GameText.GetText("DUNGEON/HAVE_ITEM", "You", "<color=#" + ColorUtility.ToHtmlStringRGB(UIItem.GetGradeColor(item.grade)) + ">" + room.item.name + "</color>"), false));

        ProgressManager.Instance.Update(ProgressType.CollectItem, "", 1);
        room.item = null;
        gameObject.SetActive(false);
    }
Exemple #4
0
    private IEnumerator Win(Monster.Meta meta)
    {
        dungeon_move.touch_input.block_count++;
        dungeon.data.current_room.monster = null;
        GameManager.Instance.player.enemy_slain_count++;

        int  prevPlayerLevel = GameManager.Instance.player.level;
        Stat stat            = GameManager.Instance.player.stats;
        int  rewardCoin      = meta.reward.coin + (int)Random.Range(-meta.reward.coin * 0.1f, meta.reward.coin * 0.1f);

        rewardCoin += (int)(rewardCoin * 0.1f * dungeon.level);
        int bonusCoin = (int)(rewardCoin * stat.GetStat(StatType.CoinBonus) / 100.0f);
        int rewardExp = meta.reward.exp + (int)Random.Range(-meta.reward.exp * 0.1f, meta.reward.exp * 0.1f);

        rewardExp += (int)(rewardExp * 0.1f * dungeon.level);
        int bonusExp = (int)(rewardExp * stat.GetStat(StatType.ExpBonus) / 100.0f);

        GameManager.Instance.player.ChangeCoin(rewardCoin + bonusCoin, false);
        GameManager.Instance.player.AddExp(rewardExp + bonusExp);

        GameManager.Instance.player.collect_coin_count += rewardCoin + bonusCoin;
        GameManager.Instance.player.total_exp          += rewardExp + bonusExp;

        if (meta.reward_item_chance > Random.Range(0.0f, 100.0f))
        {
            if ("" == meta.reward.item_id)
            {
                dungeon.data.current_room.item = EquipItemManager.Instance.GetRandomMeta();
            }
            else
            {
                dungeon.data.current_room.item = ItemManager.Instance.FindMeta <Item.Meta>(meta.reward.item_id);
            }
        }

        Database.Execute(Database.Type.UserData, "UPDATE user_data SET player_coin=" + GameManager.Instance.player.coin);
        ProgressManager.Instance.Update(ProgressType.EnemiesSlain, meta.id, 1);

        CreateCoins(rewardCoin + bonusCoin);

        for (int i = prevPlayerLevel; i < GameManager.Instance.player.level; i++)
        {
            yield return(player_exp.SetCurrent(player_exp.max, 0.3f));

            player_exp.max = GameManager.Instance.player.meta.GetMaxExp(i);
            yield return(player_exp.SetCurrent(0.0f, 0.0f));
        }

        player_exp.max        = GameManager.Instance.player.meta.GetMaxExp(GameManager.Instance.player.level);
        player_exp.current    = GameManager.Instance.player.exp;
        player_health.max     = GameManager.Instance.player.max_health;
        player_health.current = GameManager.Instance.player.cur_health;

        string battleResult = "";

        battleResult += GameText.GetText("DUNGEON/BATTLE/DEFEATED", "You", meta.name) + "\n";
        battleResult += "Coins : +" + rewardCoin + (0 < bonusCoin ? "(" + bonusCoin + " bonus)" : "") + "\n";
        battleResult += "Exp : +" + rewardExp + (0 < bonusExp ? "(" + bonusExp + " bonus)" : "") + "\n";
        if (prevPlayerLevel < GameManager.Instance.player.level)
        {
            battleResult += "Level : " + prevPlayerLevel + " -> " + GameManager.Instance.player.level + "\n";
        }

        yield return(GameManager.Instance.ui_textbox.Write(battleResult, false));

        mini_map.CurrentPosition(dungeon.data.current_room.id);
        dungeon_move.touch_input.block_count--;
    }
Exemple #5
0
    public IEnumerator BattleStart(Monster.Meta monsterMeta)
    {
        Util.EventSystem.Publish(EventID.Dungeon_Battle_Start);

        turn_count   = 0;
        battle_pause = true;

        player_attack_per_second = Mathf.Max(0.35f, GameManager.Instance.player.speed / monsterMeta.speed);
        player_attack_per_second = Mathf.Min(3.5f, player_attack_per_second);
        enemy_attack_per_second  = 1.0f;
        player_preemptive_score  = player_attack_per_second;
        enemy_preemptive_score   = enemy_attack_per_second;
        battle_result            = BattleResult.Invalid;

        monster.gameObject.SetActive(true);
        monster.Init(monsterMeta, dungeon.level);

        InitButtons();
        GameManager.Instance.player.on_attack  = null;
        GameManager.Instance.player.on_attack += (Unit.AttackResult result) =>
        {
            AudioManager.Instance.Play(AudioManager.BATTLE_ATTACK, false);
            SceneDungeon.log.Write(GameText.GetText("DUNGEON/BATTLE/HIT", "You", monster.meta.name) + "(-" + (int)result.damage + ")");
        };
        GameManager.Instance.player.on_defense  = null;
        GameManager.Instance.player.on_defense += (Unit.AttackResult result) =>
        {
            iTween.ShakePosition(Camera.main.gameObject, new Vector3(0.3f, 0.3f, 0.0f), 0.2f);
            Effect_PlayerDamage effectPlayerDamage = player_damage_effects[Random.Range(0, player_damage_effects.Length)];
            effectPlayerDamage.gameObject.SetActive(true);

            UIDamageText damageText = GameObject.Instantiate <UIDamageText>(damage_text_prefab);
            damageText.gameObject.SetActive(false);
            damageText.Init(result, Color.red);
            damageText.transform.SetParent(player_health.transform, false);
            damageText.transform.localPosition = new Vector3(player_health.rect.x + player_health.rect.width * player_health.gauge.fillAmount, player_health.rect.y + player_health.rect.height / 2, 0.0f);
            damage_texts.Add(damageText);
            player_health.current = GameManager.Instance.player.cur_health;
        };

        monster.data.on_attack  = null;
        monster.data.on_attack += (Unit.AttackResult result) =>
        {
            AudioManager.Instance.Play(AudioManager.BATTLE_ATTACK, false);
            monster.animator.SetTrigger("Attack");
            SceneDungeon.log.Write("<color=red>" + GameText.GetText("DUNGEON/BATTLE/HIT", monster.meta.name, "You") + "(-" + (int)result.damage + ")</color>");
        };

        monster.data.on_defense  = null;
        monster.data.on_defense += (Unit.AttackResult result) =>
        {
            StartCoroutine(monster.OnDamage(result));
            UIDamageText damageText = GameObject.Instantiate <UIDamageText>(damage_text_prefab);
            damageText.gameObject.SetActive(false);
            damageText.Init(result, Color.white);
            if ("" == result.type)
            {
                damageText.life_time = 0.8f;
                damageText.transform.SetParent(monster.ui_health.transform, false);
                damageText.transform.localPosition = new Vector3(monster.ui_health.rect.x + monster.ui_health.rect.width * monster.ui_health.gauge.fillAmount, monster.ui_health.rect.y + monster.ui_health.rect.height / 2, 0.0f);
            }
            else
            {
                damageText.life_time = 3.0f;
                damageText.transform.SetParent(monster.damage_effect_spot, false);
                damageText.transform.localPosition = new Vector3(0.0f, 400.0f * GameManager.Instance.canvas.scaleFactor, 0.0f);
            }
            damage_texts.Add(damageText);
            monster.ui_health.current = monster.data.cur_health;
        };

        yield return(StartCoroutine(monster.ColorTo(Color.black, Color.white, 1.0f)));

        battle_pause = false;
        touch_input.block_count--;

        while (BattleResult.Invalid == battle_result)
        {
            yield return(new WaitForSeconds(0.1f));
        }

        touch_input.block_count++;

        if (BattleResult.Win == battle_result)
        {
            yield return(monster.Die());
        }
        monster.meta = null;

        runaway_button.gameObject.SetActive(false);
        monster.gameObject.SetActive(false);

        //Util.EventSystem.Publish(EventID.MiniMap_Show);
        Util.EventSystem.Publish <BattleResult>(EventID.Dungeon_Battle_Finish, battle_result);
    }
Exemple #6
0
 private void Start()
 {
     touch_input.on_touch_up += (Vector3 position) =>
     {
         touch_input.gameObject.SetActive(false);
         //touch_collider.enabled = false;
         if (Room.Type.Lock == room.type)
         {
             List <KeyItem> keyItems = GameManager.Instance.player.inventory.GetItems <KeyItem>();
             if (0 == keyItems.Count)
             {
                 if (null != textbox_coroutine)
                 {
                     StopCoroutine(textbox_coroutine);
                 }
                 textbox_coroutine = StartCoroutine(GameManager.Instance.ui_textbox.Write(GameText.GetText("ERROR/UNLOCK_DOOR"), false));
                 touch_input.gameObject.SetActive(true);
                 return;
             }
             GameManager.Instance.player.inventory.Remove(keyItems[0].slot_index);
         }
         StartCoroutine(Open());
     };
 }
 public void UpdateText()
 {
     TextObject.text = GameText.GetText();
 }