Exemplo n.º 1
0
        public void OnPlayerForwardCheckpoint(Player p, CheckPoint cp)
        {
            Player.CircuitState PlayerState = p.GetCircuitState();

            int iTotalCP = m_CheckPointList.Count;
            int iLastPlayerCP = PlayerState.iCheckPoint;
            int iCurrCP = cp.GetIndex();

            int iNumLaps = PlayerState.iLaps;

            if (iLastPlayerCP == 0 && iCurrCP == 0)
            {
                PlayerState.iLaps += 1;
            }

            iLastPlayerCP = iLastPlayerCP < 0 ? 0 : iLastPlayerCP;

            int iNextCP = (iLastPlayerCP + 1) % iTotalCP;
            int iPrevCP = (iLastPlayerCP - 1) % iTotalCP;
            iPrevCP = iPrevCP < 0 ? (iTotalCP - 1) : iPrevCP;

            // The player is going on the right direction
            PlayerState.iCheckPoint = iNextCP;
        }
Exemplo n.º 2
0
            public int Compare(Player p1, Player p2)
            {
                if (p1 == null || p2 == null || p1 == p2)
                    return 0;

                Player.CircuitState state1 = p1.GetCircuitState();
                Player.CircuitState state2 = p2.GetCircuitState();

                //Debug.Print("Laps " + state1.iLaps + ", " + state2.iLaps);
                if (state1.iLaps > state2.iLaps)
                {
                    //Debug.Print("Laps: Player " + p1.GetName() + " before than " + p2.GetName());
                    return -1;
                }
                else if (state1.iLaps == state2.iLaps)
                {
                    //Debug.Print("CP: " + state1.iCheckPoint + ", " + state2.iCheckPoint);
                    if (state1.iCheckPoint > state2.iCheckPoint)
                    {
                        //Debug.Print("CP: Player " + p1.GetName() + " before than " + p2.GetName());
                        return -1;
                    }
                    else if (state1.iCheckPoint == state2.iCheckPoint)
                    {
                        //Debug.Print("Dist: " + state1.fSqCheckpointDist + ", " + state2.fSqCheckpointDist);
                        if (state1.fSqCheckpointDist <= state2.fSqCheckpointDist)
                        {
                            //Debug.Print("Dist: Player " + p1.GetName() + " before than " + p2.GetName());
                            return -1;
                        }
                    }
                }

                //Debug.Print("Player " + p2.GetName() + " before than " + p1.GetName());
                return 1;
            }
Exemplo n.º 3
0
        public void OnPlayerBackwardCheckpoint(Player p, CheckPoint cp)
        {
            Player.CircuitState PlayerState = p.GetCircuitState();

            int iTotalCP = m_CheckPointList.Count;
            int iLastPlayerCP = PlayerState.iCheckPoint;
            int iCurrCP = cp.GetIndex();

            if (iCurrCP != iLastPlayerCP)
            {
                int iNextCP = (iCurrCP + 1) % iTotalCP;

                // The player is going on the wrong direction (backwards)
                PlayerState.iCheckPoint = iCurrCP;
            }
        }