Exemplo n.º 1
0
    public void UpdateTargetsOfWaitingPlayers()
    {
        foreach (var item in players)
        {
            PlayerBase pb = item.GetComponent <PlayerBase>();
            if (pb.Role() != "GoalKeeper")
            {
                FieldPlayer fp = item.GetComponent <FieldPlayer>();
                if (fp.GetFSM() == null)
                {
                    Debug.Log("No FSM");
                }
                if (fp.GetFSM().IsInstate(Wait.instance) || fp.GetFSM().IsInstate(ReturnToHomeRegion.instance))
                {
                    //Debug.Log("원래는 fp.steering().settarget(~~)\n https://github.com/wangchen/Programming-Game-AI-by-Example-src/blob/master/Buckland_Chapter4-SimpleSoccer/SoccerTeam.cpp");

                    if (fp.Team().teamColor == TeamColor.Blue)
                    {
                        fp.Steering().SetTarget((fp.Team().initialRegion[fp.ID() - 6]));
                    }
                    else
                    {
                        fp.Steering().SetTarget((fp.Team().initialRegion[fp.ID() - 1]));
                    }
                    //    fp.gameObject.GetComponent<PlayerBase>().Steering().SetTarget(fp.HomeRegion());
                }
            }
        }
    }
    // 대기중인 플레이어의 목표 지점을 최신화
    public void UpdateTargetsOfWaitingPlayers()
    {
        foreach (var item in players)
        {
            PlayerBase pb = item.GetComponent <PlayerBase>();
            if (pb.Role() != "GoalKeeper")
            {
                FieldPlayer fp = item.GetComponent <FieldPlayer>();

                if (fp.GetFSM() == null)
                {
                    Debug.LogError("No FSM");
                }

                // 본래의 위치로 돌아가게 한다.
                if (fp.GetFSM().IsInstate(Wait.instance) || fp.GetFSM().IsInstate(ReturnToHomeRegion.instance))
                {
                    if (fp.Team().teamColor == TeamColor.Blue)
                    {
                        fp.Steering().SetTarget((fp.Team().initialRegion[fp.Id() - 6]));
                    }
                    else
                    {
                        fp.Steering().SetTarget((fp.Team().initialRegion[fp.Id() - 1]));
                    }
                }
            }
        }
    }