public void OnSceneLoaded(bool bFrontEnd) { spawnCarswClients = !bFrontEnd; RaceManager raceMan = GameObject.FindObjectOfType <RaceManager>(); List <tk.TcpClient> clients = _server.GetClients(); foreach (tk.TcpClient client in clients) { if (_server.debug) { Debug.Log("init network client."); } InitClient(client); } if (GlobalState.bCreateCarWithoutNetworkClient && !bFrontEnd && clients.Count == 0 && raceMan == null) { CarSpawner spawner = GameObject.FindObjectOfType <CarSpawner>(); if (spawner) { if (_server.debug) { Debug.Log("spawning car."); } spawner.Spawn(null); } } }
// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.S)) { GuestManager.SaveGuestData(); } if (TheRaceManager.hasRaceStarted) { gameObject.SetActive(false); PreRaceCam.Priority = 0; } CurrentTotalPot = 0; CurrentTotalShowPool = 0; CurrentTotalPlacePool = 0; RaceManager racemanagerScript = TheRaceManager.GetComponent <RaceManager>(); foreach (BetData bD in racemanagerScript.CurrentRaceBets) { if (bD.BetType == "win") { CurrentTotalPot += bD.BetAmount; WinPool.text = CurrentTotalPot.ToString(); } if (bD.BetType == "show") { CurrentTotalShowPool += bD.BetAmount; ShowPool.text = CurrentTotalShowPool.ToString(); } if (bD.BetType == "place") { CurrentTotalPlacePool += bD.BetAmount; PlacePool.text = CurrentTotalPlacePool.ToString(); } } }
private void Awake() { if (Instance == null) { Instance = this; } }
public void Init() { startId = new MockRiderIdUnit("StartId"); endId = new MockRiderIdUnit("EndId"); timer = new MockTimingUnit(); source = new CancellationTokenSource(); TrackerConfig config = new TrackerConfig { EndMatchTimeout = 20, StartTimingGateId = 0, EndTimingGateId = 1 }; //riders are addded in the SimulateRace method tracker = new RaceTracker(timer, startId, endId, config, new List <Rider>()); subject = new RaceManager(); subject.Start(tracker, new List <IDisplayUnit> { timer }); SimulateRace(); //wait for the tracker to process all events Thread.Sleep(2000); subject.Stop(); }
public MainForm(Character c = null) { InitializeComponent(); //Race foreach (Race r in RaceManager.getRaces()) { RaceComboBox.Items.Add(r.RaceName); } //Class foreach (Profession p in ProfessionManager.getProfessions()) { ClassComboBox.Items.Add(p.ProfessionName); } if (c == null) { _char = new Character(); } else { _char = c; } UpdateView(); }
// Handle detecting incoming invitations. public void UpdateInvitation() { if (InvitationManager.Instance == null) { return; } // if an invitation arrived, switch to the "invitation incoming" GUI // or directly to the game, if the invitation came from the notification Invitation inv = InvitationManager.Instance.Invitation; if (inv != null) { if (InvitationManager.Instance.ShouldAutoAccept) { // jump straight into the game, since the user already indicated // they want to accept the invitation! InvitationManager.Instance.Clear(); RaceManager.AcceptInvitation(inv.InvitationId); NavigationUtil.ShowPlayingPanel(); } else { // show the "incoming invitation" screen NavigationUtil.ShowInvitationPanel(); } } }
void Update() { if (mParticipantId == null) { MakeVisible(false); return; } RaceManager mgr = RaceManager.Instance; if (mParticipantId != null && mgr != null) { float progress = mgr.GetRacerProgress(mParticipantId); float diff = StartX + (EndX - StartX) * progress - gameObject.transform.position.x; if (diff > MaxAnimSpeed * Time.deltaTime) { diff = MaxAnimSpeed * Time.deltaTime; } else if (diff < -MaxAnimSpeed * Time.deltaTime) { diff = -MaxAnimSpeed * Time.deltaTime; } gameObject.transform.Translate(new Vector3(diff, 0.0f, 0.0f), Space.World); if (mBlink) { MakeVisible(!mBlink || 0 != (int)(Time.time / 0.25f) % 3); } } }
void Awake() { if (instance != null) { source = GetComponent <AudioSource>(); if (instance.source.clip != source.clip) { instance.source.clip = source.clip; if (instance.source.clip != null) { instance.source.Play(); } } Destroy(gameObject); } else { instance = this; source = GetComponent <AudioSource>(); if (source == null) { Debug.LogError("No Audio Source"); } DontDestroyOnLoad(gameObject); } if (_raceManager == null) { _raceManager = FindObjectOfType <RaceManager>(); } }
void OnTriggerEnter(Collider col) { Debug.Log("got coll w" + col.gameObject.name); if (col.gameObject.name != targetName) { return; } Transform parent = col.transform.parent; if (parent == null) { return; } Debug.Log("parent" + parent.gameObject.name); RaceManager rm = GameObject.FindObjectOfType <RaceManager>(); if (rm) { rm.OnCarOutOfBounds(parent.gameObject); } }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.gameObject.CompareTag("ground")) { RaceManager.EndRace(true); } }
public void CleanUp() { PlayGamesPlatform.Instance.RealTime.LeaveRoom(); TearDownTrack(); mRaceState = RaceState.Aborted; sInstance = null; }
public void TestMethod1() { RaceManager MyRaceManager = new RaceManager(); Athlete Athlete1 = new Athlete(1, "Camron1", "Martinez1", "Male1", 1, "Okay1", 1001, 1, 1, 2); Athlete Athlete2 = new Athlete(2, "Camron2", "Martinez2", "Male2", 2, "Okay2", 1002, 2, 2, 3); Athlete Athlete3 = new Athlete(3, "Camron3", "Martinez3", "Male3", 3, "Okay3", 1003, 3, 3, 4); Athlete Athlete4 = new Athlete(4, "Camron4", "Martinez4", "Male4", 4, "Okay4", 1004, 4, 4, 5); MyRaceManager.MyRunners.Add(Athlete1); MyRaceManager.MyRunners.Add(Athlete2); MyRaceManager.MyRunners.Add(Athlete3); MyRaceManager.MyRunners.Add(Athlete4); System.Net.IPEndPoint endpoint1 = new System.Net.IPEndPoint(127001, 12000); string MessageFromCommunicator = "DidNotFinish,1,6666"; string[] SplitMessage = MessageFromCommunicator.Split(','); string message = SplitMessage[0]; MessageFactory messageFactory = new MessageFactory(); //MyRaceManager.MyMessageProcessor = MyRaceManager.GetMessageProcessor(MessageFromCommunicator); MyRaceManager.MyMessageProcessor = messageFactory.GetMessageProcessor(message); MyRaceManager.MyMessageProcessor.Process(SplitMessage, ref MyRaceManager, endpoint1); Assert.AreEqual(MyRaceManager.MyRunners[0].status, "DidNotFinish"); Assert.AreEqual(MyRaceManager.MyRunners[0].lastUpdatedTime, 6666); Assert.AreEqual(MyRaceManager.MyRunners[0].finishTime, 6666); }
void Awake() { if (raceManager == null) { raceManager = GetComponent <RaceManager>(); } }
void Start() { if (myTurtleData.baseAcceleration > 0) { gameObject.name = myTurtleData.name; myEndurance = myTurtleData.baseEndurance; myAcceleration = myTurtleData.baseAcceleration; mySurface = myTurtleData.favoriteSurface; } else { myAcceleration = Random.Range(1, 4); myEndurance = Random.Range(1, 4); } transform.localScale = new Vector3(1 + (myTurtleData.MyScaleX * 0.01f), 1 + (myTurtleData.MyScaleY * 0.01f), 1); RaceResultsColumn1 = ""; RaceResultsColumn2 = ""; RaceResultsColumn3 = ""; RaceResultsColumn4 = ""; idleCounter = Random.Range(0, 15); usedMats = ""; HowManyTurtlesFinished = 0; RaceManagerScriptRef = RaceManagerReference.GetComponent <RaceManager>(); inRaceResultsText = RaceManagerScriptRef.inRaceResultsGiuText; myAnimator = gameObject.GetComponent <Animator> (); BaseSpeed += Random.Range(-10, 10) * .01f; SpeedChangeTimer = SpeedChangeTickRate; oddsGui = UIOdds.GetComponent <TextMeshProUGUI>(); //TurtleNamer TurlteNamerScriptRef = RaceManagerReference.GetComponent<TurtleNamer>(); //gameObject.name = TurlteNamerScriptRef.GiveNewRandomName(); //gameObject.name = TurlteNamerScriptRef.PossibleNames[Random.Range(0,TurlteNamerScriptRef.PossibleNames.Length -1)]; UIName.GetComponent <TextMeshProUGUI>().text = gameObject.name; }
// Use this for initialization private void Start() { ball = GetComponent <Ball>(); //Find AI skill level from race manager RaceManager raceManager = FindObjectOfType <RaceManager>(); if (raceManager) { skillLevel = raceManager.Settings.AISkill; switch (skillLevel) { case AISkillLevel.Retarded: targetPointMaxOffset = 200; break; case AISkillLevel.Average: targetPointMaxOffset = 20; break; case AISkillLevel.Dank: targetPointMaxOffset = 0f; break; } } //Set initial target //Doing this from a RacePlayer, as it's done when changing checkpoints, doesn't work - when RacePlayer's //constructor runs, this component has not yet been added to the AI ball yet. target = StageReferences.Active.checkpoints[0].FirstAINode; }
public void Setup(int player) { _playerIndex = player; _boat = RaceManager.RaceData.boats[_playerIndex].Boat; _totalLaps = RaceManager.GetLapCount(); _totalPlayers = RaceManager.RaceData.boats.Count; _timeOffset = Time.time; switch (AppSettings.Instance.speedFormat) { case AppSettings.SpeedFormat._Kph: _speedFormat = AppSettings.SpeedFormat._Kph; speedFormatText.text = "kph"; break; case AppSettings.SpeedFormat._Mph: _speedFormat = AppSettings.SpeedFormat._Mph; speedFormatText.text = "mph"; break; } StartCoroutine(SetupPlayerMarkers(player)); StartCoroutine(SetupPlayerMapMarkers()); StartCoroutine(CreateGameStats()); }
// Use this for initialization void Awake() { if (instance == null) { instance = this; } else { Destroy(this); } DontDestroyOnLoad(this); mapIndex = 0; fishCount = 0; gameActive = false; secondsRemaining = secondsToWaitInLobby; pointTable = new Dictionary <NetworkConnection, int>(); nameTable = new Dictionary <NetworkConnection, string>(); fishTable = new Dictionary <NetworkConnection, int>(); EventManager.StartListening(EventType.InitGame, OnStart); //EventManager.StartListening(EventType.NextLevel, LoadNextLevel); EventManager.StartListening(EventType.EndGame, OnEnd); }
IEnumerator WatchRaceStatus() { //Debug.Log("UiManager.WatchRaceStatus"); while (RaceManager.IsRaceInProgress() == false) { yield return(null); } CountdownTimerHud.Hide(); raceButton.GetComponentInChildren <Text>().text = Constants.StopRace; raceInfoHud.StartWatchRaceStatus(); while (RaceManager.IsRaceInProgress() == true) { yield return(new WaitForSeconds(0.1f)); } if (RaceManager.IsReady()) { closeRaceInfoHudButton.gameObject.SetActive(true); } raceButton.GetComponentInChildren <Text>().text = Constants.StartRace; }
// Use this for initialization void Start() { spawnBoxes = spawnAreas.GetComponentsInChildren <BoxCollider>(); //PlaceSpawners(10); raceManager = FindObjectOfType <RaceManager>(); topdownCam.enabled = false; }
protected override void DoGUI() { Invitation inv = InvitationManager.Instance.Invitation; if (inv == null) { gameObject.GetComponent <MainMenuGui>().MakeActive(); return; } string inviterName = null; inviterName = (inv.Inviter == null || inv.Inviter.DisplayName == null) ? "Someone" : inv.Inviter.DisplayName; GuiLabel(CenterLabelCfg, inviterName + " is challenging you to a quiz race!"); if (GuiButton(AcceptButtonCfg)) { InvitationManager.Instance.Clear(); RaceManager.AcceptInvitation(inv.InvitationId); gameObject.GetComponent <RaceGui>().MakeActive(); } else if (GuiButton(DeclineButtonCfg)) { InvitationManager.Instance.DeclineInvitation(); gameObject.GetComponent <MainMenuGui>().MakeActive(); } }
private void SaveRaceProgress(RaceManager race) { RaceProgress = race.RaceProgress; PassedDistance = (int)race.PassedDistance; PassedTime = (int)race.TimeSiceStart; ObstaclesCount = race.ObstaclesCount; }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.gameObject.CompareTag("finish")) { RaceManager.EndRace(false); } }
void Awake() { instance = this; carTrainer = CarTrainer.instance; raceManager = RaceManager.raceManager; AnalysePlotArea(); }
public GameObject getLeadingPlayer() { int maxLap = 0; int maxId = 0; List <RaceManager> leaders = new List <RaceManager>(); foreach (int playerId in playerIds) { RaceManager player = players[playerId]; if (player.lap > maxLap || (player.lap == maxLap && player.currentSectionId > maxId)) { leaders = new List <RaceManager>(); leaders.Add(player); maxId = player.currentSectionId; maxLap = player.lap; } else if (player.lap == maxLap && player.currentSectionId == maxId) { leaders.Add(player); } } if (leaders.Count > 1) { return(sections[maxId].getLeadingPlayer(leaders)); } return(leaders[0].gameObject); }
public void Configure(RaceManager raceManager) { // Add race state listener. raceManager.OnRaceStateChanged.AddListener(OnRaceStateChanged); CheckRaceState(raceManager.CurrentState); }
// Update is called once per frame void Update() { FinishLine FL = GameObject.FindObjectOfType <FinishLine>(); if (FL) { if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began && bRaceStarted && FL.bRaceEnded) { OnClickStartBtn(); } } if (bRaceStarted) { RaceManager RaceGuru = GameObject.FindObjectOfType <RaceManager>(); if (RaceGuru) { int PlayerSp = (int)(RaceGuru.PlayerCar.GetComponent <CarController>().CurrentSpeed); int OponentSp = (int)(RaceGuru.OponentCar.GetComponent <CarController>().CurrentSpeed); PlayerSpeedText.SetText(PlayerSp.ToString() + "MPH"); OponentSpeedText.SetText(OponentSp.ToString() + "MPH"); } } }
void AddLapRow() { Vector2 sizeDelta = rectTransform.sizeDelta; sizeDelta.y += rowHeight; rectTransform.sizeDelta = sizeDelta; lapLabel = GameObject.Instantiate(lapLabelPrefab).GetComponent <Text>(); lapLabel.text = string.Format(Constants.LapLabelFormat, RaceManager.GetLapCount()); lapLabel.gameObject.transform.SetParent(column1.transform); lapLabel.transform.localScale = Vector2.one; lapElapsedTime = GameObject.Instantiate(elapsedLapTimePrefab).GetComponent <Text>(); lapElapsedTime.text = Constants.ElapsedLapTime; lapElapsedTime.gameObject.transform.SetParent(column2.transform); lapElapsedTime.transform.localScale = Vector2.one; GameObject blank = GameObject.Instantiate(raceInfoHudBlankPrefab); blank.transform.SetParent(column3.transform); blank.transform.localScale = Vector2.one; blank = GameObject.Instantiate(raceInfoHudBlankPrefab); blank.transform.SetParent(column4.transform); blank.transform.localScale = Vector2.one; blank = GameObject.Instantiate(raceInfoHudBlankPrefab); blank.transform.SetParent(column5.transform); blank.transform.localScale = Vector2.one; }
public bool Initialize(GameMain gameMain, out string reason) { _gameMain = gameMain; if (!base.Initialize((gameMain.ScreenWidth / 2) - 320, (gameMain.ScreenHeight / 2) - 320, 640, 640, StretchableImageType.MediumBorder, gameMain, false, gameMain.Random, out reason)) { return(false); } _randomSprite = SpriteManager.GetSprite("RandomRace", gameMain.Random); if (_randomSprite == null) { reason = "RandomRace sprite does not exist."; return(false); } _raceButtons = new BBStretchButton[15]; _raceScrollBar = new BBScrollBar(); _raceBackground = new BBStretchableImage(); _raceDescription = new BBTextBox(); _okButton = new BBStretchButton(); _raceManager = gameMain.RaceManager; for (int i = 0; i < _raceButtons.Length; i++) { _raceButtons[i] = new BBStretchButton(); if (!_raceButtons[i].Initialize(string.Empty, ButtonTextAlignment.LEFT, StretchableImageType.ThinBorderBG, StretchableImageType.ThinBorderFG, _xPos + 10, _yPos + 10 + (i * 40), 280, 40, gameMain.Random, out reason)) { return(false); } } //Add 1 for the random race option int scrollValue = (_raceManager.Races.Count + 1) < _raceButtons.Length ? _raceButtons.Length : (_raceManager.Races.Count + 1); if (!_raceScrollBar.Initialize(_xPos + 290, _yPos + 10, 600, _raceButtons.Length, scrollValue, false, false, gameMain.Random, out reason)) { return(false); } _maxVisible = (_raceManager.Races.Count + 1) > _raceButtons.Length ? _raceButtons.Length : (_raceManager.Races.Count + 1); if (_raceManager.Races.Count < 15) { _raceScrollBar.SetEnabledState(false); } if (!_raceBackground.Initialize(_xPos + 310, _yPos + 10, 310, 550, StretchableImageType.ThinBorderBG, gameMain.Random, out reason)) { return(false); } if (!_raceDescription.Initialize(_xPos + 315, _yPos + 325, 300, 215, true, true, "RaceSelectionDescriptionTextBox", gameMain.Random, out reason)) { return(false); } if (!_okButton.Initialize("Select Race", ButtonTextAlignment.CENTER, StretchableImageType.ThinBorderBG, StretchableImageType.ThinBorderFG, _xPos + 310, _yPos + 570, 310, 40, gameMain.Random, out reason)) { return(false); } RefreshRaceLabels(); RefreshRaceDescription(); reason = null; return(true); }
void Awake() { control = this; raceCar1.isKinematic = true; raceCar2.isKinematic = true; raceCar3.isKinematic = true; raceCar4.isKinematic = true; }
public static void CreateQuickGame() { sInstance = new RaceManager(); PlayGamesPlatform.Instance.RealTime.CreateQuickGame(QuickGameOpponents, QuickGameOpponents, GameVariant, sInstance); }
public static void CreateWithInvitationScreen() { sInstance = new RaceManager(); PlayGamesPlatform.Instance.RealTime.CreateWithInvitationScreen( MinOpponents, MaxOpponents, GameVariant, sInstance); }
void Awake() { instance = this; }
void Start() { startTime = Time.time; race_manager_instance = RaceManager.instance; }
// public CarLibrary carLib; // Use this for initialization void Start () { lastUpdate = Time.time; REF = this; Time.timeScale = 1f; carCamera = GameObject.Find("Main_Camera").GetComponent<IRDSCarCamera>(); levLoad = GameObject.Find ("LevelLoad").GetComponent<IRDSLevelLoadVariables>(); levLoad.laps = 3; //Screen.SetResolution(640, 480, true); carCamera.ActivateRoadCamera (); if (TeamDatabase.REF == null) { return; } GameObject light = GameObject.Find("Directional Light"); Light dl = light.GetComponent<Light>(); switch(SettingsScreen.shadowLevel) { case(0):dl.shadows = LightShadows.None;break; case(1):dl.shadows = LightShadows.Hard;break; case(2):dl.shadows = LightShadows.Soft;break; } NGUIDisabler.PAUSED_TIME_SCALE = 0.1f; // Time.timeScale = 4; manager = GameObject.Find ("IRDSManager").GetComponent<IRDSManager> (); statistics =manager.GetComponentInChildren<IRDSStatistics>(); statistics.startRaceManually = true; // statistics.StartTheRace(); carCamera = manager.GetComponentInChildren<IRDSCarCamera>(); placeCars = manager.gameObject.GetComponentInChildren<IRDSPlaceCars> (); // BetterList<IRDSCarControllerAI> allCars = new BetterList<IRDSCarControllerAI> (); genericRaceGUI = GameObject.Find("GenericRaceGUI"); UILabel totalLaps = GameObject.Find("LAP").GetComponent<UILabel>(); driver1Label = GameObject.Find("DriverMessage1").GetComponent<UILabel>(); driver2Label = GameObject.Find("DriverMessage2").GetComponent<UILabel>(); simSpeedBtn = GameObject.Find("SimSpeedButton").GetComponent<UIButton>(); simSpeedLbl = GameObject.Find("SimSpeedButton").GetComponent<UILabel>(); simSpeedBtn.onClick.Add(new EventDelegate(this,"onSimSpeedChange")); if(genericRaceGUI!=null) { genericRaceGUI.gameObject.SetActive(false); } List<GTDriver> driversInRace = ChampionshipRaceSettings.ACTIVE_RACE.driversForRace(); totalLaps.text = "/ "+this.levLoad.laps; GameObject raceStarters = GameObject.Find("RaceLineupPanel"); if(raceStarters!=null) { raceStartersTable = raceStarters.GetComponent<RaceStarterTable>(); raceStartersTable.activate(driversInRace); } for(int i = 0;i<this.fv.Count;i++) { fv[i].enabled = true; } if(levLoad.raceStartType!=IRDSLevelLoadVariables.RaceStartType.Rolling) { StartCoroutine(makeCars()); } else { raceStartersTable.allowRaceStart(); } // }
public void SetRaceManager(RaceManager rm) { raceManager = rm; }
public static void AcceptFromInbox() { sInstance = new RaceManager(); PlayGamesPlatform.Instance.RealTime.AcceptFromInbox(sInstance); }
void Awake() { //create an instance instance = this; }
void Awake() { price = new Price(); race_manager_instance = RaceManager.instance; }
public static void AcceptInvitation(string invitationId) { sInstance = new RaceManager(); PlayGamesPlatform.Instance.RealTime.AcceptInvitation(invitationId, sInstance); }
void Awake() { if(instance != null && instance != this) { Destroy(this.gameObject); return; } else { instance = this; } CountdownTimerReset(3); }