public override void ClickAction(Land clickLand) { base.ClickAction(clickLand); if (!BattleManager.Instance.CanAttack) { return; } //空闲状态时只能操作自己阵营的地块 if (clickLand.CampID == BattleManager.Instance.CurCamp.campID && !LandOperateMenu.isActiveAndEnabled) { Debug.Log("点击了自己的地块"); //当前状态的进攻地块就是点击的地块 attackLand = clickLand; //打开右键菜单 SetLandOperateMenu(); } else { Debug.Log("空闲状态下的取消操作"); MyRound.Cancel(); } }
/// <summary> /// 弹出并设置地块操作菜单 /// </summary> private void SetLandOperateMenu() { //先清空按钮点击事件 LandOperateMenu.attackBtn.onClick.RemoveAllListeners(); LandOperateMenu.bombBtn.onClick.RemoveAllListeners(); //弹出菜单选项 LandOperateMenu.ShowSelfOnLandPosition(attackLand.CoordinateInMap); LandOperateMenu.attackBtn.onClick.AddListener( delegate() { if (CurMouseLandCanAttack(attackLand)) { //进入军队进攻状态 MyRound.CurAttackState = MyRound.AttackStateDic[AttackStateEnum.ArmyAttack]; MyRound.CurAttackState.attackLand = attackLand; //周围敌方格子有高亮框 MyRound.HighLightNeighborEnemyLands(attackLand); } else { //提示不能进攻 GlobalUImanager.Instance.OpenPopTip().GetComponent <PopTip>().SetContent("军队无法前进!"); } HideLandOpearteMenu(); }); //如果该地没有大炮,则该操作为买炮 if (!attackLand.cannon.isOwned) { LandOperateMenu.SetBombTextContent("购买高炮"); LandOperateMenu.bombBtn.onClick.AddListener( delegate() { if (BattleManager.Instance.CurCamp.PurchaseCannon()) { attackLand.cannon.isOwned = true; //设置贴图为有炮的 //todo BattleManager.Instance.SetLandCannonTile(attackLand); if (BattleManager.Instance.BATTLE_EVENT_PURCHASE_CANNON != null) { BattleManager.Instance.BATTLE_EVENT_PURCHASE_CANNON(); } } else { GlobalUImanager.Instance.OpenPopTip().GetComponent <PopTip>().SetContent("你没钱奥!"); } HideLandOpearteMenu(); }); } else//否则是轰炸其他地块 { LandOperateMenu.SetBombTextContent("轰炸"); LandOperateMenu.bombBtn.onClick.AddListener( delegate() { //如果没冷却就轰炸 if (!attackLand.cannon.isInCool) { //进入轰炸进攻状态 MyRound.CurAttackState = MyRound.AttackStateDic[AttackStateEnum.BombAttack]; MyRound.CurAttackState.attackLand = attackLand; //周围敌方格子有高亮框 MyRound.HighLightNeighborEnemyLands(attackLand); } else//否则提示处于冷却中 { GlobalUImanager.Instance.OpenPopTip().GetComponent <PopTip>().SetContent("高炮处于冷却中!"); } HideLandOpearteMenu(); }); } }