void Update() { if (Input.GetMouseButtonDown(0)) { FBGrid g = GetTileUnderMouse(); if (g != null) { //触发鼠标左键点击事件 FBGridClickEventArgs e = new FBGridClickEventArgs(0, g); if (OnFBGridClick != null) { OnFBGridClick(this, e); } } } if (Input.GetMouseButtonDown(1)) { FBGrid g = GetTileUnderMouse(); if (g != null) { //触发鼠标右键点击事件 FBGridClickEventArgs e = new FBGridClickEventArgs(1, g); if (OnFBGridClick != null) { OnFBGridClick(this, e); } } } }
private void MapOnGridClick(object sender, FBGridClickEventArgs e) { //当前场景不是LevelBuilder 不能编辑 if (gameObject.scene.name != "LevelBuilder") { return; } if (Level == null) { return; } if (e.MouseButton == 0 && !f_road.Contains(e.Grid)) { e.Grid.CanHold = !e.Grid.CanHold; } if (e.MouseButton == 1 && !e.Grid.CanHold) { if (f_road.Contains(e.Grid)) { f_road.Remove(e.Grid); } else { f_road.Add(e.Grid); } } }
private void OnMapGridClick(object sender, FBGridClickEventArgs e) { FBGameModel game = GetModel <FBGameModel>(); //游戏还未开始,那么不操作菜单 if (!game.IsPlaying) { return; } //如果有菜单显示,那么隐藏菜单 if (FBUITowerPopup.Instance.IsPopShow) { SendEvent(FBConsts.E_TowerHide); return; } FBGrid grid = e.Grid; if (!grid.CanHold) { SendEvent(FBConsts.E_TowerHide); return; } if (grid.Data == null) { FBShowTowerCreatArgs args = new FBShowTowerCreatArgs() { Position = f_map.GetPosition(grid), UpSide = grid.Index_Y < FBMap.RowCount / 2 }; SendEvent(FBConsts.E_ShowTowerCreat, args); } else { FBShowTowerUpgradeArgs args = new FBShowTowerUpgradeArgs() { Tower = grid.Data as FBTower }; SendEvent(FBConsts.E_ShowTowerUpgrade, args); } }