protected override void mapBindings() { injectionBinder.Bind <IMatrixManager>().ToValue(new MatrixManager(10, 10)).ToSingleton(); { GameObject obj = new GameObject("ShapeManager"); ShapeManager shapeM = obj.AddComponent <ShapeManager>(); shapeM.length = 3; shapeM.Initialize(); injectionBinder.Bind <IShapeManager>().ToValue(shapeM).ToSingleton(); } { GameObject obj = new GameObject("TouchControl"); obj.AddComponent <TouchControl>(); injectionBinder.Bind <ITouchControl>().ToValue(obj.GetComponent <TouchControl>()).ToSingleton(); } //View/Mediator binding //This Binding instantiates a new MyMediator whenever as TetrisView //Fires its Awake method. The Mediator communicates to/from the View //and to/from the App. This keeps dependencies between the view and the app //separated. mediationBinder.Bind <TetrisView>().To <MyMediator>(); //Event/Command binding //commandBinder.Bind(ExampleEvent.REQUEST_WEB_SERVICE).To<CallWebServiceCommand>(); //The START event is fired as soon as mappings are complete. //Note how we've bound it "Once". This means that the mapping goes away as soon as the command fires. commandBinder.Bind(ContextEvent.START).To <StartCommand>().Once(); }
protected override void Initialize() { ShapeManager.Initialize(graphics); ScreenManager.Initialize(defaultWindowWidth, defaultWindowHeight); Camera.Initialize(); StaticCamera.Initialize(); base.Initialize(); }
// Use this for initialization void Start() { //构建战场矩阵Matrix for (int row = 0; row < MAP_ROW_COUNT; row++) { for (int col = 0; col < MAP_COL_COUNT; col++) { GameObject go = Instantiate(Resources.Load("Prefabs/Unit") as GameObject); go.transform.localScale = Vector3.one * UNIT_SCALE; go.transform.position = GetPositionByIndex(row, col); _squareList.Add(go); } } //构建随机颜色库 _randomColorList.Add(Color.red); _randomColorList.Add(Color.green); _randomColorList.Add(Color.blue); _randomColorList.Add(Color.yellow); _randomColorList.Add(Color.cyan); _randomColorList.Add(Color.magenta); //构建接下来将出现的图形库,这里显示4组将要出现的图形 for (int index = 0; index < 4; index++) { for (int row = 0; row < 4; row++) { for (int col = 0; col < 4; col++) { GameObject go = Instantiate(Resources.Load("Prefabs/Unit") as GameObject); go.transform.localScale = Vector3.one * NEXT_UNIT_SCALE; go.transform.position = GetNextPositionByIndexes(index, row, col); go.GetComponent <Renderer>().material.color = Color.black; _nextOnesSquareList.Add(go); } } } ShapeManager.Initialize(); InitialMap(); _currentShape = null; //初始化参数 _fallDownTimeAccumulation = 0f; _needRestart = false; }