Пример #1
0
    IEnumerator AIBlocker()
    {
        roundUI_showing = true;
        yield return(new WaitUntil(() => !roundUI_showing));


        List <GameObject> temp_AI_units = new List <GameObject>(map_ctr.AI_units);

        foreach (GameObject ob in temp_AI_units)
        {
            Debug.Log(ob.name);
            AIUnit enemy = ob.GetComponent <AIUnit>();

            //Find where the AI unit should go
            int move_range;
            //if enemy is on muddy tile, move_range becomes 1
            if (map_ctr.map_tiles[enemy.currentPos].GetComponent <Tile>().tile_type == "Muddy")
            {
                move_range = 1;
            }
            else
            {
                move_range = enemy.moveRange;
            }
            if (ob.name.StartsWith("NianShou"))
            {
                map_ctr.all_paths = map_ctr.Search_solution(enemy.currentPos, move_range, gameRound, ob.tag, checkPeach);
            }
            else
            {
                map_ctr.all_paths = map_ctr.Search_solution(enemy.currentPos, move_range, gameRound, ob.tag, checkEnemy);
            }

            int solution_key = -1;
            foreach (int i in map_ctr.all_paths.Keys)
            {
                solution_key = i;
            }
            if (solution_key != -1)
            {
                map_ctr.path = map_ctr.all_paths[solution_key];
            }
            map_ctr.all_paths.Clear();
            //AI unit move in the front end
            enemy.acting = true;
            yield return(new WaitUntil(() => !enemy.acting));
        }


        gameRound = "Player";
        endTurnButton.SetActive(true);

        foreach (GameObject ob in map_ctr.units_state)
        {
            if (ob != null && ob.CompareTag("PlayerUnit"))
            {
                ob.GetComponent <UserUnit>().turnComplete = false;
                ob.GetComponent <UserUnit>().moveComplete = false;
            }
        }

        //debug for printing turn
        Debug.Log("turn :" + gameRound);

        roundUI_showing = true;
        yield return(new WaitUntil(() => !roundUI_showing));
    }