// ------------------ Methods override protected void Awake() { base.Awake(); Debug.Log("GameController.Awake()"); GameController.OnDestroying += GameController_OnDestroying; TickController.Instantiate(); AudioController.Instantiate(); InputController.Instantiate(); ViewController.Instantiate(); ResourceController.Instantiate(); Application.targetFrameRate = 30; _screenBounds = UnityEngineReplacementUtility.Convert(GameUtility.GetOrthographicBounds(Camera.main)); SetupPools(); SetupPoolObserver(); //order matters //1 - Systems that depend on entities will internally listen for entity creation before reacting - nice! SetupSystems(); //2 SetupEntities(); //place a ball in the middle of the screen w/ velocity _pool.CreateEntity().willStartNextRound = true; }
private void ProcessResourceAddedEntity(Entity entity) { var resource = Resources.Load <GameObject>(entity.resource.resourcePath); GameObject gameObject = null; try { gameObject = UnityEngine.Object.Instantiate(resource); } catch (Exception) { Debug.Log("Cannot instantiate " + resource); } if (gameObject != null) { gameObject.transform.parent = ViewController.Instance.ViewsParent; //We want the size here. So store the bounds. //null is ok Collider collider = gameObject.GetComponent <Collider>(); if (collider != null) { entity.AddView(gameObject, UnityEngineReplacementUtility.Convert(collider.bounds)); } else { entity.AddView(gameObject, new Oultrox.Common.UnityEngineReplacement.Bounds()); } //Keep //Debug.Log("View Added: " + entity.view.gameObject); } }
private void ProcessPositionEntity(Entity entity) { ((GameObject)entity.view.gameObject).transform.position = UnityEngineReplacementUtility.Convert(entity.position.position); //Debug.Log("ProcessEntity: " + ((GameObject)entity.view.gameObject).transform.position); }