Ejemplo n.º 1
0
 public void enemyTurn()
 {
     for (int i = 0; i < enemies.Length; ++i)
     {
         if (enemies[i].gameObject.activeSelf)
         {
             if (!enemies[i].isMoveable())
             {
                 continue;
             }
             if (enemies[i].getAttack() - PlayerManager.Inst().getPlayer().getDefend() > 0)
             {
                 PlayerManager.Inst().getPlayer().GetDamaged(enemies[i].getAttack() - PlayerManager.Inst().getPlayer().getDefend());
                 Debug.Log("Player get damaged");
             }
             else
             {
                 PlayerManager.Inst().getPlayer().GetDamaged(10);
                 Debug.Log("Player get damaged");
             }
             if (enemies[i].getStatus() != StatusEffect.None)
             {
                 if (Random.Range(0, 20) < 1)
                 {
                     PlayerManager.Inst().getPlayer().setStatusEffect(enemies[i].getStatus());
                     PlayerManager.Inst().getPlayer().setStatusRemainTurn(Random.Range(4, 8));
                 }
             }
         }
     }
     Combination = "";
     InGameUIManager.Inst().combinationTextUpdate();
     turnOver();
 }
Ejemplo n.º 2
0
 void Update()
 {
     if (getHP() <= 0)
     {
         getAnimator().SetBool("dead", true);
         GameStateManager.Inst().setState(State.END);
         InGameUIManager.Inst().resultTextUpdate();
         InGameUIManager.Inst().OnStateChanged(State.END);
     }
 }
Ejemplo n.º 3
0
 public void turnOver()
 {
     if (currentTurn == GameTurn.PLAYER)
     {
         for (int i = 0; i < enemies.Length; ++i)
         {
             if (enemies[i].gameObject.activeSelf)
             {
                 if (enemies[i].getStatusEffect() == StatusEffect.Corrosion)
                 {
                     enemies[i].GetDamaged((int)(enemies[i].getMaxHP() * 0.05f));
                     enemies[i].mobDead();
                 }
                 if (enemies[i].getStatusEffect() == StatusEffect.Frostbite)
                 {
                     enemies[i].setMoveable(!enemies[i].isMoveable());
                 }
                 if (enemies[i].getStatusEffect() != StatusEffect.None)
                 {
                     enemies[i].setStatusRemainTurn(enemies[i].getStatusRemainTurn() - 1);
                     if (enemies[i].getStatusRemainTurn() <= 0)
                     {
                         enemies[i].setStatusEffect(StatusEffect.None);
                         enemies[i].setMoveable(true);
                     }
                 }
             }
         }
         currentTurn = GameTurn.ENEMY;
         cost        = ++maxCost;
         if (maxCost > 10)
         {
             cost = maxCost = 10;
         }
         InGameUIManager.Inst().costTextUpdate();
     }
     else
     {
         if (PlayerManager.Inst().getPlayer().getStatusEffect() == StatusEffect.Frostbite)
         {
             PlayerManager.Inst().getPlayer().setMoveable(!PlayerManager.Inst().getPlayer().isMoveable());
         }
         if (PlayerManager.Inst().getPlayer().getStatusEffect() != StatusEffect.None)
         {
             PlayerManager.Inst().getPlayer().setStatusRemainTurn(PlayerManager.Inst().getPlayer().getStatusRemainTurn() - 1);
             if (PlayerManager.Inst().getPlayer().getStatusRemainTurn() <= 0)
             {
                 PlayerManager.Inst().getPlayer().setStatusEffect(StatusEffect.None);
                 PlayerManager.Inst().getPlayer().setMoveable(true);
             }
         }
         currentTurn = GameTurn.PLAYER;
     }
     InGameUIManager.Inst().HPbarUpdate();
 }
Ejemplo n.º 4
0
 void Start()
 {
     distance = 5 + villageNum * 3;
     progress = 0;
     if (GameStateManager.Inst().getState() == State.PAUSE)
     {
         GameStateManager.Inst().setState(State.INGAME);
     }
     InGameUIManager.Inst().progressUpdate(progress);
     InGameUIManager.Inst().combinationTextUpdate();
     InGameUIManager.Inst().HPbarUpdate();
 }
Ejemplo n.º 5
0
 public void endBattle()
 {
     Combination = "";
     battleTimer = 5.0f;
     Debug.Log("Battle is ended");
     ++progress;
     InGameUIManager.Inst().progressUpdate(progress, battleTimer);
     InGameUIManager.Inst().combinationTextUpdate();
     InGameUIManager.Inst().HPbarUpdate();
     for (int i = 0; i < enemies.Length; ++i)
     {
         Destroy(enemies[i].gameObject);
     }
 }
Ejemplo n.º 6
0
    public void battleStart()
    {
        mob_number = Random.Range(1, 4);
        int mob_seed;

        InBattle = true;

        AttackReady = false;
        maxCost     = cost = 1;

        InGameUIManager.Inst().costTextUpdate();
        enemies = new ObjectMob[mob_number];
        for (int i = 0; i < mob_number; ++i)
        {
            mob_seed = Random.Range(0, 2);
            GameObject mob = InGameUIManager.Inst().GenerateMob(mobPrefab[mob_seed], i);
            mob.GetComponent <ObjectMob>().setmobSeed(mob_seed);
            mob.name   = "monster" + i.ToString();
            enemies[i] = mob.GetComponent <ObjectMob>();
            enemies[i].setLevel(Random.Range(villageNum * 10, villageNum * 10 + 10));
            enemies[i].getLVtext().text = "LV." + (enemies[i].getLevel() + 1).ToString();
            int hp = 0, atk = 0, exp = 0;
            switch (mob_seed)
            {
            case 0:
                hp  = 1000;
                atk = 100;
                exp = 50;
                break;

            case 1:
                hp  = 1250;
                atk = 100;
                exp = 55;
                break;
            }
            for (int k = 0; k < enemies[i].getLevel(); ++k)
            {
                hp  += (int)(enemies[i].getLevel() * 13 + enemies[i].getMaxHP() * 0.17 + 17);
                atk += (int)(enemies[i].getLevel() * 2.77 + enemies[i].getAttack() * 0.1);
                exp += (int)(enemies[i].getLevel() * 2.3);
            }
            enemies[i].setMaxHP(hp);
            enemies[i].setHP(hp);
            enemies[i].setAttack(atk);
            enemies[i].setEXP(exp);
        }

        InGameUIManager.Inst().HPbarUpdate();
    }
Ejemplo n.º 7
0
 void Update()
 {
     if (battleTimer > 0 && !InBattle)
     {
         battleTimer -= GameTime.deltaTime;
         return;
     }
     else if (battleTimer <= 0)
     {
         battleTimer = 1;
         if (progress >= distance)
         {
             if (villageNum == PlayerManager.villageProgress)
             {
                 villageNum = ++PlayerManager.villageProgress;
             }
             GameStateManager.Inst().setState(State.END);
             InGameUIManager.Inst().resultTextUpdate();
             InGameUIManager.Inst().OnStateChanged(State.END);
         }
         else
         {
             battleStart();
         }
     }
     if (waitSecond > 0)
     {
         waitSecond -= GameTime.deltaTime;
         return;
     }
     if (currentTurn == GameTurn.PLAYER)
     {
         playerTurn();
     }
     else
     {
         enemyTurn();
     }
 }
 void Awake()
 {
     stateM = GameStateManager.Inst();
     gameUI = InGameUIManager.Inst();
 }
    public void OnButtonClicked(GameObject button)
    {
        switch (button.name)
        {
        case "PauseButton":
        {
            stateM.setState(State.PAUSE);
            gameUI.OnStateChanged(State.PAUSE);
            break;
        }

        case "ResumeButton":
        {
            stateM.setState(State.INGAME);
            gameUI.OnStateChanged(State.INGAME);
            break;
        }

        case "MainMenuButton":
        {
            //SaveHelper.Save(InGameSystemManager.Inst(), "/gamedata");
            //SaveHelper.Save(PlayerManager.Inst(), "/gamedata");
            //SaveHelper.Save(InventoryManager.Inst(), "/gamedata");
            SceneManager.LoadScene("Title");
            break;
        }

        case "VillageButton":
        {
            SceneManager.LoadScene("Village");
            break;
        }

        case "CButton":
        case "SButton":
        case "HButton":
        case "OButton":
        case "PButton":
        {
            if (!InGameSystemManager.Inst().isInBattle())
            {
                return;
            }
            if (InGameSystemManager.Inst().getCombination().Length == 6)
            {
                Debug.Log("Combination length is max");
                return;
            }
            switch (button.name[0])
            {
            case 'C':
                if (InGameSystemManager.Inst().getCost() < 2)
                {
                    Debug.Log("Not enough cost");
                    return;
                }
                InGameSystemManager.Inst().useCost(2f);
                break;

            case 'H':
            case 'O':
                if (InGameSystemManager.Inst().getCost() < 1)
                {
                    Debug.Log("Not enough cost");
                    return;
                }
                InGameSystemManager.Inst().useCost(1f);
                break;

            case 'S':
            case 'P':
                if (InGameSystemManager.Inst().getCost() < 1f)
                {
                    Debug.Log("Not enough cost");
                    return;
                }
                InGameSystemManager.Inst().useCost(1f);
                break;
            }
            InGameUIManager.Inst().costTextUpdate();
            InGameSystemManager.Inst().addCombination(button.name[0]);
            InGameUIManager.Inst().combinationTextUpdate();
            Debug.Log("current combination : " + InGameSystemManager.Inst().getCombination());
            break;
        }

        case "SkillBookButton":
        {
            stateM.setState(State.SKILLINFO);
            gameUI.OnStateChanged(State.SKILLINFO);
            break;
        }
        }
    }