コード例 #1
0
    public void GoalTouched(AgentSoccer.Team scoredTeam)
    {
        foreach (var ps in playerStates)
        {
            if (ps.agentScript.team == scoredTeam)
            {
                RewardOrPunishPlayer(ps, m_Academy.strikerReward, m_Academy.goalieReward);
            }
            else
            {
                RewardOrPunishPlayer(ps, m_Academy.strikerPunish, m_Academy.goaliePunish);
            }
            if (m_Academy.randomizePlayersTeamForTraining)
            {
                ps.agentScript.ChooseRandomTeam();
            }

            if (scoredTeam == AgentSoccer.Team.Purple)
            {
                StartCoroutine(GoalScoredSwapGroundMaterial(m_Academy.purpleMaterial, 1));
            }
            else
            {
                StartCoroutine(GoalScoredSwapGroundMaterial(m_Academy.blueMaterial, 1));
            }
            if (goalTextUI)
            {
                StartCoroutine(ShowGoalUI());
            }
        }
    }
コード例 #2
0
    public void GoalTouched(AgentSoccer.Team scoredTeam)                                   // 골터치 함수다. 득점에 따른 상과 벌점을 주고, 팀과 에이전트의 역할을 정하고, 이긴팀의 바닦색을 바꿔주고, UI에 득점했다고 표시한다.
    {
        foreach (var ps in playerStates)                                                   // 플레이어의 상태를 반복하는데 조건이 있다.
        {
            if (ps.agentScript.team == scoredTeam)                                         //득점하면 상주고 >>>>>> 상을 준 값이 중요함.
            {
                RewardOrPunishPlayer(ps, m_Academy.strikerReward, m_Academy.goalieReward); // 스트라이크와 골라이에게 보상을 준다.
            }
            else
            {
                RewardOrPunishPlayer(ps, m_Academy.strikerPunish, m_Academy.goaliePunish); //득점을 못했으니 벌 >>>>>> 벌준값도 중요함..
            }
            if (m_Academy.randomizePlayersTeamForTraining)                                 //SoccerAcademdmy의 bool 값으로 기본설정은 True로 무조건 랜덤으로 팀이 정해짐, 이건 AgentsSoccer.cs에서 team and role정함
            {
                ps.agentScript.ChooseRandomTeam();
            }

            if (scoredTeam == AgentSoccer.Team.Purple)
            {
                StartCoroutine(GoalScoredSwapGroundMaterial(m_Academy.purpleMaterial, 1));
            }
            else
            {
                StartCoroutine(GoalScoredSwapGroundMaterial(m_Academy.blueMaterial, 1));
            }
            if (goalTextUI) // 골을 넣으면 UI에 표시
            {
                StartCoroutine(ShowGoalUI());
            }
        }
    }
コード例 #3
0
 public void updateScore(AgentSoccer.Team scoredTeam)
 {
     if (scoredTeam == AgentSoccer.Team.red)
     {
         redscoreText.GetComponent <Text>().text = string.Format("{0}", redTeamScore);
     }
     else
     {
         bluescoreText.GetComponent <Text>().text = string.Format("{0}", blueTeamScore);
     }
     Debug.Log(string.Format("{0:HH:mm:ss}, Blue: {1}, Red: {2}", System.DateTime.Now, blueTeamScore, redTeamScore));
 }
コード例 #4
0
 void UpdateHud(AgentSoccer.Team team)
 {
     if (team == AgentSoccer.Team.red)
     {
         scoreRed++;
         TeamRedScore.GetComponent <UnityEngine.UI.Text>().text = scoreRed.ToString();
     }
     else
     {
         scoreBlue++;
         TeamBlueScore.GetComponent <UnityEngine.UI.Text>().text = scoreBlue.ToString();
     }
 }
コード例 #5
0
    public void GoalTouched(AgentSoccer.Team scoredTeam)
    {
        foreach (PlayerState ps in playerStates)
        {
            if (ps.agentScript.team == scoredTeam)
            {
                RewardOrPunishPlayer(ps, academy.strikerReward, academy.goalieReward);
            }
            else
            {
                RewardOrPunishPlayer(ps, academy.strikerPunish, academy.goaliePunish);
            }
            if (academy.randomizePlayersTeamForTraining)
            {
                ps.agentScript.ChooseRandomTeam();
            }

            if (scoredTeam == AgentSoccer.Team.red)
            {
                StartCoroutine(GoalScoredSwapGroundMaterial(academy.redMaterial, 1));
            }
            else
            {
                StartCoroutine(GoalScoredSwapGroundMaterial(academy.blueMaterial, 1));
            }

            if (goalTextUI)
            {
                StartCoroutine(ShowGoalUI());
            }
        }
        if (!updatedScore)
        {
            if (scoredTeam == AgentSoccer.Team.red)
            {
                redTeamScore++;
            }
            else
            {
                blueTeamScore++;
            }
            updatedScore = true;
            updateScore(scoredTeam);
        }
    }
コード例 #6
0
    public void GoalTouched(AgentSoccer.Team scoredTeam)
    {
        foreach (var ps in playerStates)
        {
            if (ps.agentScript.team == scoredTeam)
            {
                ps.agentScript.AddReward(1);
            }
            else
            {
                ps.agentScript.AddReward(-1);
            }
            ps.agentScript.Done();  //all agents need to be reset

            if (goalTextUI)
            {
                StartCoroutine(ShowGoalUI());
            }
        }
    }
コード例 #7
0
    public Vector3 GetRandomSpawnPos(AgentSoccer.AgentRole role, AgentSoccer.Team team)
    {
        var xOffset = 0f;

        if (role == AgentSoccer.AgentRole.Goalie)
        {
            xOffset = 13f;
        }
        if (role == AgentSoccer.AgentRole.Striker)
        {
            xOffset = 7f;
        }
        if (team == AgentSoccer.Team.Blue)
        {
            xOffset = xOffset * -1f;
        }
        var randomSpawnPos = ground.transform.position +
                             new Vector3(xOffset, 0f, 0f)
                             + (Random.insideUnitSphere * 2);

        randomSpawnPos.y = ground.transform.position.y + 2;
        return(randomSpawnPos);
    }