예제 #1
0
    public void Update_TeamState()
    {
        int num_left = 0, num_right = 0;

        for (int i = 0; i < Bot_List.Count; ++i)
        {
            Robot t = Bot_List[i];
            if (t.bot_area != Robot.Bot_Area.INGAME)
            {
                continue;
            }
            if (t.is_left_team)
            {
                num_left++;
            }
            else
            {
                num_right++;
            }
        }

        for (int i = 0; i < Bot_List.Count; ++i)
        {
            GameAIBot t = Bot_List[i].GetComponent <GameAIBot>();
            if (t == null)
            {
                continue;
            }
            t.CallBack_Update_TeamState(num_left, num_right);
        }
    }
예제 #2
0
    public void GoRevive_Teammate()
    {
        if (chase_bot_idx == -1) // 살릴애 할당 못받은 애들은 그냥 공격
        {
            FindKill_Enemy();
            return;
        }

        Debug.Log(this.name + " Save " + chase_bot_idx + "th Bot~~~~~~~~~~~~~");

        if (chase_idx != -1)
        {
            return;
        }

        chase_idx    = GameManager.instance.Give_ChasingObject();
        chase_target = GameManager.instance.ChasingObj_List[chase_idx].transform;

        //// Notify To Prisoner
        GameAIBot t = GameManager.instance.Bot_List[chase_bot_idx].GetComponent <GameAIBot>();

        if (t == null)
        {
            return;            // If Player
        }
        if (t.is_left_team != is_left_team)
        {
            return;                                 // enemy
        }
        t.Transit_Prison(bot_idx);
    }
예제 #3
0
 public void NOTI_BallShot()
 {
     for (int i = 0; i < Bot_List.Count; ++i)
     {
         GameAIBot aibot = Bot_List[i].GetComponent <GameAIBot>();
         if (aibot != null)
         {
             aibot.MSG_BallShot();
         }
     }
 }
예제 #4
0
 public void NOTI_BallStore(int ball_index, int bot_index)
 {
     for (int i = 0; i < Bot_List.Count; ++i)
     {
         GameAIBot aibot = Bot_List[i].GetComponent <GameAIBot>();
         if (aibot != null)
         {
             aibot.MSG_BallStore(bot_index);
         }
     }
 }
예제 #5
0
 public void NOTI_BallRespawn(int res_idx, Vector3 res_pos)
 {
     for (int i = 0; i < Bot_List.Count; ++i)
     {
         GameAIBot aibot = Bot_List[i].GetComponent <GameAIBot>();
         if (aibot != null)
         {
             aibot.MSG_BallRespawn(res_idx, res_pos);
         }
     }
 }
예제 #6
0
    public int FindBot_GetBall(bool is_left, int res_idx, Vector3 ball_pos)
    {
        int   target_bot_idx = -1;
        float dis            = 1000;

        for (int i = 0; i < Bot_List.Count; ++i)
        {
            GameAIBot AIBot = Bot_List[i].GetComponent <GameAIBot>();
            if (AIBot == null || AIBot.is_left_team != is_left || AIBot.has_ball) // if player or not possible
            {
                continue;
            }
            if (AIBot.bot_area != Robot.Bot_Area.INGAME)
            {
                continue;
            }

            Vector3 test_pos = AIBot.transform.localPosition;
            float   d        = Vector3.Distance(test_pos, ball_pos);
            if (d < dis)
            {
                dis            = d;
                target_bot_idx = AIBot.bot_idx;
            }
        }

        if (target_bot_idx < 0)
        {
            Debug.Log("Not Exist Proper Bot");
            return(target_bot_idx);
        }

        // Order
        Debug.Log(target_bot_idx + "th Bot Heading To Get Ball");
        Bot_List[target_bot_idx].GetComponent <GameAIBot>().HeadingToGetBall(res_idx);

        // Order to free bot
        //for (int i = 0; i < Bot_List.Count; ++i)
        //{
        //    GameAIBot AIBot = Bot_List[i].GetComponent<GameAIBot>();
        //    if (AIBot == null) continue;
        //    if (AIBot.bot_area != Robot.Bot_Area.INGAME) continue;
        //    if (AIBot.is_left_team != is_left) continue;
        //    if (AIBot.has_ball || AIBot.assigned_respawn > -1) continue;

        //    if (i == target_bot_idx)
        //        AIBot.HeadingToGetBall(res_idx);
        //    else
        //        AIBot.CallBack_FindBot_GetBall();
        //}

        return(target_bot_idx);
    }
예제 #7
0
 public void NOTI_Revive(int bot_idx)
 {
     for (int i = 0; i < Bot_List.Count; ++i)
     {
         GameAIBot t = Bot_List[i].GetComponent <GameAIBot>();
         if (t == null)
         {
             continue;
         }
         t.MSG_Revive(bot_idx);
     }
 }
예제 #8
0
    private void AIBot_Respawn()
    {
        int bot_index = Bot_List.Count - 1;

        for (int i = 0; i < Bot_Number_Per_Team * 2; ++i)
        {
            GameAIBot obBot = null;
            bot_index += 1;

            obBot         = GameObject.Instantiate(pf_Bot) as GameAIBot;
            obBot.bot_idx = bot_index;
            obBot.Set_Team(i < Bot_Number_Per_Team);

            // set position
            int     gap     = 4;
            Vector3 bot_pos = Vector3.right * 12;
            if (Bot_Number_Per_Team % 2 == 0)
            {
                bot_pos.z = -gap * (Bot_Number_Per_Team / 2f - 1f) - (gap / 2f) + gap * (i % Bot_Number_Per_Team);
                if (i < Bot_Number_Per_Team)
                {
                    bot_pos.x *= -1;
                }
            }
            else
            {
                bot_pos.z = -gap * (Bot_Number_Per_Team - 1) / 2f + gap * (i % Bot_Number_Per_Team);
                if (i < Bot_Number_Per_Team)
                {
                    bot_pos.x *= -1;
                }
            }

            obBot.gameObject.transform.localPosition = bot_pos;
            obBot.Play_Style = (GameAIBot.AIStyle)UnityEngine.Random.Range(0, 2);
            Bot_List.Add(obBot);
        }
    }
예제 #9
0
    public void FindRevive_TeamMate(bool is_left)
    {
        /// 1. 이미 할당 된 죄수 파악
        List <int> marked_prisoners = new List <int>();

        for (int i = 0; i < Bot_List.Count; ++i)
        {
            GameAIBot bot = Bot_List[i].GetComponent <GameAIBot>();
            if (bot == null)
            {
                continue;
            }
            if (bot.bot_area != Robot.Bot_Area.INGAME)
            {
                continue;
            }
            if (bot.is_left_team != is_left)
            {
                continue;
            }
            //if (bot.Team_State == GameAIBot.TeamState.ML || bot.Team_State == GameAIBot.TeamState.MM) continue;
            if (bot.chase_bot_idx == -1)
            {
                continue;
            }
            marked_prisoners.Add(bot.chase_bot_idx);
        }

        /// 2. 새로 들어온 죄수 파악
        List <Robot> new_prisoners = new List <Robot>();

        for (int i = 0; i < Bot_List.Count; ++i)
        {
            Robot bot = GameManager.instance.Bot_List[i];
            if (is_left == bot.is_left_team)
            {
                if (bot.bot_area == Robot.Bot_Area.PRISON)
                {
                    if (!marked_prisoners.Contains(bot.bot_idx))
                    {
                        new_prisoners.Add(bot);
                    }
                }
            }
        }

        /// 2. 가까운 팀원죄수 할당 (공을 가지고 있는 애, OX or OO)
        for (int i = 0; i < new_prisoners.Count; ++i)
        {
            Vector3 prisoner_pos = new_prisoners[i].transform.localPosition;
            float   dis          = 1000;
            int     target_idx   = -1;
            for (int j = 0; j < Bot_List.Count; ++j)
            {
                GameAIBot bot = Bot_List[j].GetComponent <GameAIBot>();
                if (bot == null)
                {
                    continue;
                }
                if (bot.bot_area != Robot.Bot_Area.INGAME)
                {
                    continue;
                }
                if (bot.is_left_team != is_left)
                {
                    continue;
                }
                if (!bot.has_ball)
                {
                    continue;
                }
                if (bot.Team_State == GameAIBot.TeamState.LL && bot.Play_Style == GameAIBot.AIStyle.OFFENSIVE)
                {
                    continue;
                }
                if (bot.chase_bot_idx != -1)
                {
                    continue;
                }
                if (bot.chase_bot_idx == new_prisoners[i].bot_idx)
                {
                    target_idx = -1; break;
                }

                float d = Vector3.Distance(prisoner_pos, bot.transform.localPosition);
                if (d < dis)
                {
                    dis        = d;
                    target_idx = j;
                }
            }

            if (target_idx != -1)
            {
                Bot_List[target_idx].GetComponent <GameAIBot>().chase_bot_idx = new_prisoners[i].bot_idx;
            }
        }

        for (int i = 0; i < Bot_List.Count; ++i)
        {
            GameAIBot bot = Bot_List[i].GetComponent <GameAIBot>();
            if (bot == null)
            {
                continue;
            }
            if (bot.bot_area != Robot.Bot_Area.INGAME)
            {
                continue;
            }
            if (bot.is_left_team != is_left)
            {
                continue;
            }
            if (!bot.has_ball)
            {
                continue;
            }
            if (bot.Team_State == GameAIBot.TeamState.LL && bot.Play_Style == GameAIBot.AIStyle.OFFENSIVE)
            {
                continue;
            }
            if (bot.Team_State == GameAIBot.TeamState.ML || bot.Team_State == GameAIBot.TeamState.MM)
            {
                continue;
            }

            bot.GoRevive_Teammate();
        }

        return;
    }
예제 #10
0
    public void FindBot_Disturb_Revive(bool is_left)
    {
        List <int> marked_prisoners = new List <int>();

        for (int i = 0; i < Bot_List.Count; ++i)
        {
            GameAIBot bot = Bot_List[i].GetComponent <GameAIBot>();
            if (bot == null)
            {
                continue;
            }
            if (bot.bot_area != Robot.Bot_Area.INGAME)
            {
                continue;
            }
            if (bot.is_left_team != is_left)
            {
                continue;
            }
            if (bot.Team_State == GameAIBot.TeamState.LL || bot.Team_State == GameAIBot.TeamState.LM)
            {
                continue;
            }
            if (bot.chase_bot_idx == -1)
            {
                continue;
            }
            marked_prisoners.Add(bot.chase_bot_idx);
        }
        /// 1. 죄수 파악
        List <Robot> new_prisoners = new List <Robot>();

        for (int i = 0; i < Bot_List.Count; ++i)
        {
            Robot bot = GameManager.instance.Bot_List[i];
            if (is_left != bot.is_left_team)
            {
                if (bot.bot_area == Robot.Bot_Area.PRISON)
                {
                    if (!marked_prisoners.Contains(bot.bot_idx))
                    {
                        new_prisoners.Add(bot);
                    }
                }
            }
        }

        /// 2. 가까운 죄수 할당 (ofensive 인 애들중 XO)
        for (int i = 0; i < new_prisoners.Count; ++i)
        {
            Vector3 prisoner_pos = new_prisoners[i].transform.localPosition;
            float   dis          = 1000;
            int     target_idx   = -1;
            for (int j = 0; j < Bot_List.Count; ++j)
            {
                GameAIBot bot = Bot_List[j].GetComponent <GameAIBot>();
                if (bot == null)
                {
                    continue;
                }
                if (bot.bot_area != Robot.Bot_Area.INGAME)
                {
                    continue;
                }
                if (bot.is_left_team != is_left || bot.Play_Style == GameAIBot.AIStyle.DEFENSIVE)
                {
                    continue;
                }
                if (bot.Team_State == GameAIBot.TeamState.LL || bot.Team_State == GameAIBot.TeamState.LM)
                {
                    continue;
                }
                if (bot.chase_bot_idx != -1)
                {
                    continue;
                }
                if (bot.chase_bot_idx == new_prisoners[i].bot_idx)
                {
                    target_idx = -1; break;
                }

                float d = Vector3.Distance(prisoner_pos, bot.transform.localPosition);
                if (d < dis)
                {
                    dis        = d;
                    target_idx = j;
                }
            }

            if (target_idx != -1)
            {
                Bot_List[target_idx].GetComponent <GameAIBot>().chase_bot_idx = new_prisoners[i].bot_idx;
            }
        }

        /// 3. 추적 시작
        for (int i = 0; i < Bot_List.Count; ++i)
        {
            GameAIBot bot = Bot_List[i].GetComponent <GameAIBot>();
            if (bot == null)
            {
                continue;
            }
            if (bot.bot_area != Robot.Bot_Area.INGAME)
            {
                continue;
            }
            if (bot.is_left_team != is_left || bot.Play_Style == GameAIBot.AIStyle.DEFENSIVE)
            {
                continue;
            }
            if (bot.Team_State == GameAIBot.TeamState.LL || bot.Team_State == GameAIBot.TeamState.LM)
            {
                continue;
            }

            bot.GoDisturb_Revive();
        }
    }