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; }
public bool Init(Vector3 position, Vector3 rotation, string model_name) { m_Mesh = new Mesh(); m_Mesh.SetPosition(position); m_Mesh.SetRotation(rotation); Random r = new Random(); for (int i = 0; i < 10; i++) { int xValue = r.Next(-1000, 1000); int zValue = r.Next(-1000, 1000); ItemArea itemArea = new ItemArea(); itemArea.Init(new Vector3(xValue, 100.0f, zValue), Vector3.Zero); m_ItemAreaList.Add(itemArea); } Vector3 cp_position = Vector3.Zero; float rot = 0.0f; for (int i = 0; i < 8; i++) { cp_position = new Vector3(30000, 0, 0); rot += MathHelper.TwoPi / 8; CheckPoint cp = new CheckPoint(); cp_position = Vector3.Transform(cp_position, Matrix.CreateFromYawPitchRoll(rot, 0, 0)); cp.Init(this, null, cp_position, new Vector3(0.0f, rot, 0.0f), false, i); m_CheckPointList.Add(cp); } return m_Mesh.Load(model_name); }
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; } }