Exemple #1
0
 void DispatchGoalEvent(BallEvent e)
 {
     if (GoalEventHandler != null)
     {
         GoalEventHandler(this, e);
     }
 }
Exemple #2
0
 void OnTableContact(object sender, BallEvent e)
 {
     if (e.State == BallEvent.CollisionState.Enter)
     {
         contacts.Enqueue(ball.transform.position);
     }
 }
Exemple #3
0
 void OnTableContact(object sender, BallEvent e)
 {
     if (e.State == BallEvent.CollisionState.Exit)
     {
         source.PlayOneShot(bounce, 0.5f);
     }
 }
Exemple #4
0
 void DispatchPlayerContactEvent(BallEvent e)
 {
     if (PlayerContactEventHandler != null)
     {
         PlayerContactEventHandler(this, e);
     }
 }
Exemple #5
0
 void DispatchTableContactEvent(BallEvent e)
 {
     if (TableContactEventHandler != null)
     {
         TableContactEventHandler(this, e);
     }
 }
 void OnPlayerContact(object sender, BallEvent e)
 {
     if (e.State == BallEvent.CollisionState.Exit)
     {
         bool isAgentTeam = e.Team == agentTeam.gameObject;
         Stats.OnPlayerContact(isAgentTeam);
     }
 }
Exemple #7
0
 void OnGoal(object sender, BallEvent e)
 {
     if (e.Team == teamRed.gameObject)
     {
         source.PlayOneShot(goalA, 0.75f);
     }
     else
     {
         source.PlayOneShot(goalB, 0.75f);
     }
 }
        void OnGoal(object sender, BallEvent e)
        {
            bool hasScored = e.Object == opponentTeam.Goal;

            Stats.OnGoal(hasScored);
            AddReward(hasScored ? goalScoredReward : -goalConcededPenalty);

            if (hasScored)
            {
                agentTeam.HighlightGoal();
            }
        }
Exemple #9
0
        void OnGoal(object sender, BallEvent e)
        {
            bool hasScored = e.Object == opponentTeam.Goal;

            Stats.OnGoal(hasScored);
            AddReward(hasScored ? goalScoredReward : -goalConcededPenalty);
            matchState = hasScored ? GhostTrainerMatchState.WIN : GhostTrainerMatchState.LOSS;
            if (hasScored)
            {
                agentTeam.HighlightGoal();
            }
        }
Exemple #10
0
 void OnGoal(object sender, BallEvent e)
 {
     // Highlight.
     foreach (LineRenderer line in lines)
     {
         Color col = colors[2];
         col.a           = line.startColor.a;
         line.startColor = col;
         col.a           = line.endColor.a;
         line.endColor   = col;
     }
     draw = false;
 }
Exemple #11
0
 void OnPlayerContact(object sender, BallEvent e)
 {
     if (e.State == BallEvent.CollisionState.Exit)
     {
         if (e.Team == teamRed.gameObject)
         {
             source.PlayOneShot(kickA);
         }
         else
         {
             source.PlayOneShot(kickB);
         }
     }
 }
Exemple #12
0
 void OnPlayerContact(object sender, BallEvent e)
 {
     if (e.State == BallEvent.CollisionState.Enter)
     {
         int index = e.Team == teamRed.gameObject ? 0 : 1;
         if (index != crntTeamIndex)
         {
             contacts.Clear();
             crntTeamIndex = index;
             draw          = true;
         }
         contacts.Enqueue(e.Object.transform.position);
     }
 }
Exemple #13
0
        void OnCollision(BallEvent e)
        {
            if (e.Object.CompareTag(Tags.PLAYER))
            {
                DispatchPlayerContactEvent(e);
            }
            else if (e.Object.CompareTag(Tags.TABLE))
            {
                DispatchTableContactEvent(e);

                if (e.State == BallEvent.CollisionState.Enter)
                {
                    Vector3 p      = e.Object.transform.localPosition;
                    Vector3 normal = Mathf.Abs(p.z) > 0.5f
                        ? Vector3.back * Mathf.Sign(p.z)
                        : Vector3.left * Mathf.Sign(p.x);
                    rb.velocity = Vector3.Reflect(-e.Collision.relativeVelocity, normal) * wallBounce;
                }
            }
        }
 void OnAutoKick(object sender, BallEvent e)
 {
     Stats.OnAutoKick();
 }
Exemple #15
0
 void OnAutoKick(object sender, BallEvent e)
 {
     ReSet();
 }
Exemple #16
0
 void OnReset(object sender, BallEvent e)
 {
     ReSet();
 }
Exemple #17
0
 void OnReset(object sender, BallEvent e)
 {
     source.PlayOneShot(reset);
 }