public void SetUp() { _midScreenWidth = (float)Screen.width / 2; _throttler = new Throttler(); NetworkView = new Mock<INetworkView>(); NetworkViewOther = new Mock<INetworkView>(); _gameObject = Object.Instantiate(Resources.LoadAssetAtPath("Assets/CarRed.prefab", typeof(GameObject))) as GameObject; if (_gameObject == null) return; _autoBehaviour = _gameObject.AddComponent<CarBehaviour>(); _gameObject.GetComponent<CarBehaviour>().NetworkView = NetworkView.Object; _carDriver = new Car(_autoBehaviour) { CarObject = { NetworkView = NetworkView.Object } }; _player = new Player(_carDriver, _throttler); _gameObjectOther = Object.Instantiate(Resources.LoadAssetAtPath("Assets/CarBlue.prefab", typeof(GameObject))) as GameObject; if (_gameObjectOther == null) return; _autoBehaviourOther = _gameObjectOther.AddComponent<CarBehaviour>(); _gameObjectOther.GetComponent<CarBehaviour>().NetworkView = NetworkViewOther.Object; _carOther = new Car(_autoBehaviourOther) { CarObject = { NetworkView = NetworkViewOther.Object } }; _gameObjectCountDownController = GameObject.CreatePrimitive(PrimitiveType.Cube); _countdownController = _gameObjectCountDownController.AddComponent<CountdownController>(); MainScript.SelfPlayer = new Player { Role = new Driver() }; MainScript.SelfCar = _carDriver; }
public void Initialize() { Server = (Server)GameObject.FindGameObjectWithTag("Network").GetComponent(typeof(Server)); Client = (Client)GameObject.FindGameObjectWithTag("Network").GetComponent(typeof(Client)); // Use the NetworkWrapper so that the Server maintains it's actual functionallity. Server.Network = new NetworkWrapper(); Cars = new List<Car>(); for (int i = 0; i < GameData.CARS_AMOUNT; i++) { Cars.Add(new Car()); } NetworkController = (NetworkController)GameObject.FindGameObjectWithTag("Network").GetComponent(typeof(NetworkController)); GuiController = (GraphicalUIController)GameObject.FindGameObjectWithTag("GUI").GetComponent(typeof(GraphicalUIController)); CountdownController = (CountdownController)GameObject.FindGameObjectWithTag("CountdownController").GetComponent(typeof(CountdownController)); }
public void SetUp() { _gameObject = GameObject.CreatePrimitive(PrimitiveType.Cube); _countdownController = _gameObject.AddComponent<CountdownController>(); }