public void Update() { GameObject go = null; if(ScreenUtility.GetObjectUnderCursor(out go)) { if (go.tag == "Grid") { Grid.LightExisting(); Grid.LightTiles(go, View.Building.Type, false); View.OnInputChange(go); } } if(Input.GetMouseButtonDown(0)) { if (go != null) { int x = go.GetComponent<GridView>().X; int z = go.GetComponent<GridView>().Z; int tileCounter = 2; //2x2 minimum switch (View.Building.Type) { case BuildingType.OneByOne: tileCounter = 1; break; case BuildingType.TwoByTwo: tileCounter = 2; break; case BuildingType.ThreeByThree: tileCounter = 3; break; case BuildingType.FourByFour: tileCounter = 5; break; } if(!Grid.Check(x,z,tileCounter)) { Destroy(this.gameObject); Grid.DeLightTiles(false); Grid.DeLightTiles(true); IGridElement ge = new GridElement(x, z); View.Building.Tile = ge; QueueCreator.Add(View.Building,View.Building.Functions.ElementAt(0)); } } } if(Input.GetMouseButtonDown(1)) { Destroy(this.gameObject); //HideBuildingMenu.Dispatch(); Grid.DeLightTiles(true); Grid.DeLightTiles(false); } }
public override void Execute() { int GridSizeX = (int)GameConfig.GridSize.x; int GridSizeY = (int)GameConfig.GridSize.y; Vector2 ScreenSize = ScreenUtility.GetScreenSize(); float SplitX = 1.3f; GameObject Parent = new GameObject("Grid"); Parent.transform.parent = ContextView.transform; injectionBinder.Bind<GameObject>().ToValue(Parent).ToName(ShintoElement.Grid); for (int i = 0; i < GridSizeX; i++) { for (int j = 0; j < GridSizeY; j++) { GridElement GE = new GridElement(i, j); Vector3 Pos = Vector3.zero; Pos.x = i * SplitX; Pos.y = j * SplitX; CreateGridElementSignal.Dispatch(new Vector3( Pos.x + ScreenUtility.UnitGridSizeInUnityUnits().x, 0, Pos.y - ScreenSize.y*0.3f), GE); } } GridConstructedSignal.Dispatch(); }