// // API // // // Utility // // Bike Factory stuff static public GameObject CreateBike(IBike ib, FeGround feGround) { GameObject newBike = GameObject.Instantiate(FrontendBikeFactory.GetInstance().bikePrefab, utils.Vec3(ib.basePosition), Quaternion.identity) as GameObject; newBike.AddComponent(bikeClassTypes[ib.ctrlType]); newBike.transform.parent = feGround.transform; FrontendBike bk = (FrontendBike)newBike.transform.GetComponent("FrontendBike"); bk.Setup(ib, BeamMain.GetInstance().beamApp.mainGameInst); return(newBike); }
public static FrontendBikeFactory GetInstance() { if (instance == null) { instance = (FrontendBikeFactory)GameObject.FindObjectOfType(typeof(FrontendBikeFactory)); if (!instance) { Debug.LogError("There needs to be one active FrontendBikeFactory script on a GameObject in your scene."); } } return(instance); }
// Bikes public void OnNewBikeEvt(object sender, IBike ib) { logger.Info($"OnNewBikeEvt(). Id: {ib.bikeId}, LocalPlayer: {ib.ctrlType == BikeFactory.LocalPlayerCtrl}"); GameObject bikeGo = FrontendBikeFactory.CreateBike(ib, feGround); feBikes[ib.bikeId] = bikeGo; if (ib.ctrlType == BikeFactory.LocalPlayerCtrl) { mainObj.inputDispatch.SetLocalPlayerBike(bikeGo); mainObj.uiController.CurrentStage().transform.Find("RestartBtn")?.SendMessage("moveOffScreen", null); mainObj.uiController.CurrentStage().transform.Find("Scoreboard")?.SendMessage("SetLocalPlayerBike", bikeGo); mainObj.gameCamera.StartBikeMode(bikeGo); } else { mainObj.uiController.CurrentStage().transform.Find("Scoreboard")?.SendMessage("AddBike", bikeGo); } mainObj.uiController.ShowToast($"New Bike: {ib.name}", Toast.ToastColor.kBlue); }