// Update is called once per frame
    void Update()
    {
        // Lose state
        if (mc.peach_count == 0 || mc.user_unit_count == 0)
        {
            turn.LoseScene.SetActive(true);
        }

        //level? win/lose check
        if (Level == 0)
        {
            if (win_conditions_count == 1)
            {
                if (!mc.character_moving)
                {
                    if (!level_finished)
                    {
                        //player win, hide HUD
                        for (int i = 0; i < turn.UI.GetComponent <InGameUI>().transform.childCount; ++i)
                        {
                            turn.UI.GetComponent <InGameUI>().transform.GetChild(i).gameObject.SetActive(false);
                        }

                        //start timeline
                        if (timeline.GetComponent <PlayableDirector>().state == PlayState.Paused)
                        {
                            timeline.GetComponent <PlayableDirector>().Play();
                            mc.reset();
                            level_finished = true;
                        }
                    }
                    //timeline ends, level finishes
                    else if (timeline.GetComponent <PlayableDirector>().state == PlayState.Paused)
                    {
                        turn.WinScene.SetActive(true);
                    }
                }
            }
            else
            {
                win_conditions_count = 0;
            }
        }
    }
Example #2
0
    //Change round between player and AI, AI units from different group all act in "AI" round
    public void changeRound()
    {
        map_ctr.turn_count++;
        WG.rdsGeneEnemy--;

        if (gameRound == "Player")
        {
            for (int i = 0; i < map_ctr.map_size * map_ctr.map_size; i++)
            {
                //reduce tile fire cd
                if (map_ctr.map_tiles[i].GetComponent <Tile>().on_fire)
                {
                    map_ctr.map_tiles[i].GetComponent <Tile>().update_fire();
                }
                //traps disappear
                if (map_ctr.map_tiles[i].GetComponent <Tile>().trap != null)
                {
                    if (map_ctr.map_tiles[i].GetComponent <Tile>().trap.GetComponent <trap>().visible_time != 0)
                    {
                        map_ctr.map_tiles[i].GetComponent <Tile>().trap.GetComponent <trap>().visible_time--;
                    }
                }


                ////apply fire damage and reduce skill cd
                if (map_ctr.units_state[i] != null)
                {
                    if (map_ctr.units_state[i].tag == "PlayerUnit")
                    {
                        //apply fire damage to character if on fire
                        if (map_ctr.units_state[i].GetComponent <UserUnit>().on_fire)
                        {
                            map_ctr.units_state[i].GetComponent <UserUnit>().Health_Change(map_ctr.units_state[i].GetComponent <UserUnit>().fire_damage);
                        }
                        //apply poison damage to character if poisoned;
                        if (map_ctr.units_state[i].GetComponent <UserUnit>().poisoned)
                        {
                            map_ctr.units_state[i].GetComponent <UserUnit>().Health_Change(map_ctr.units_state[i].GetComponent <UserUnit>().poison_damage);
                        }
                        //reduce fire cd
                        if (map_ctr.units_state[i].GetComponent <UserUnit>().on_fire)
                        {
                            map_ctr.units_state[i].GetComponent <UserUnit>().fire_cd--;
                            if (map_ctr.units_state[i].GetComponent <UserUnit>().fire_cd == 0)
                            {
                                map_ctr.units_state[i].GetComponent <UserUnit>().on_fire = false;
                                map_ctr.units_state[i].GetComponent <UserUnit>().Reset_FireCD();
                            }
                        }
                        //reduce skill cd
                        if (map_ctr.units_state[i].GetComponent <UserUnit>().coolDown != 0)
                        {
                            map_ctr.units_state[i].GetComponent <UserUnit>().coolDown--;
                        }
                        if (map_ctr.units_state[i].GetComponent <UserUnit>().coolDown == 0)
                        {
                            map_ctr.units_state[i].GetComponent <UserUnit>().Reset_Skill();
                        }
                        //reduce poison cd
                        if (map_ctr.units_state[i].GetComponent <UserUnit>().poisoned)
                        {
                            map_ctr.units_state[i].GetComponent <UserUnit>().poison_cd--;
                            if (map_ctr.units_state[i].GetComponent <UserUnit>().poison_cd == 0)
                            {
                                map_ctr.units_state[i].GetComponent <UserUnit>().poisoned = false;
                                map_ctr.units_state[i].GetComponent <UserUnit>().Reset_PoisonCD();
                            }
                        }
                    }
                    else if (map_ctr.units_state[i].tag == "EnemyUnit")
                    {   //apply fire damage to enemy
                        if (map_ctr.units_state[i].GetComponent <AIUnit>().on_fire)
                        {
                            map_ctr.units_state[i].GetComponent <AIUnit>().Health_Change(map_ctr.units_state[i].GetComponent <AIUnit>().fire_damage);
                        }
                        //apply poison damage to character if poisoned;
                        if (map_ctr.units_state[i].GetComponent <AIUnit>().poisoned)
                        {
                            map_ctr.units_state[i].GetComponent <AIUnit>().Health_Change(map_ctr.units_state[i].GetComponent <AIUnit>().poison_damage);
                        }
                        //reduce fire cd
                        if (map_ctr.units_state[i].GetComponent <AIUnit>().on_fire)
                        {
                            map_ctr.units_state[i].GetComponent <AIUnit>().fire_cd--;
                            if (map_ctr.units_state[i].GetComponent <AIUnit>().fire_cd == 0)
                            {
                                map_ctr.units_state[i].GetComponent <AIUnit>().on_fire = false;
                                map_ctr.units_state[i].GetComponent <AIUnit>().Reset_FireCD();
                            }
                        }
                        //reduce poison cd
                        if (map_ctr.units_state[i].GetComponent <AIUnit>().poisoned)
                        {
                            map_ctr.units_state[i].GetComponent <AIUnit>().poison_cd--;
                            if (map_ctr.units_state[i].GetComponent <AIUnit>().poison_cd == 0)
                            {
                                map_ctr.units_state[i].GetComponent <AIUnit>().poisoned = false;
                                map_ctr.units_state[i].GetComponent <AIUnit>().Reset_PoisonCD();
                            }
                        }
                    }
                }
            }

            map_ctr.reset();
            endTurnButton.SetActive(false);

            //reset AI turncomplete
            if (map_ctr.AI_units.Count >= 1)
            {
                foreach (GameObject ob in map_ctr.AI_units)
                {
                    ob.GetComponent <AIUnit>().turnComplete = false;
                    ob.GetComponent <AIUnit>().moveComplete = false;
                }
            }

            bool enemyNone = true;
            foreach (GameObject ob in map_ctr.units_state)
            {
                if (ob != null && ob.tag == "EnemyUnit")
                {
                    enemyNone = false;
                }
            }

            if (WG.rdsGeneEnemy == 0 || enemyNone)
            {
                Wave_Num += 1;
                WG.generateEnemy();
            }


            StartCoroutine(map_routine());
        }
    }