void Update() { if (Input.GetMouseButtonDown(0)) { if (EventSystem.current.IsPointerOverGameObject() == false) { //开发炮台的建造 Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; bool isCollider = Physics.Raycast(ray, out hit, 1000, LayerMask.GetMask("MapCube")); if (isCollider) { MapCube mapCube = hit.collider.GetComponent <MapCube>(); Debug.Log(mapCube.name + " " + mapCube.isFlipped); // 扫雷,显示数字 if (!mapCube.isFlipped) // 没翻,还要判定有没有插旗 { if (myFH.flagModel) //如果有按flag 按钮进入插旗模式 { //插旗,生成旗帜模型, mapCube.buildFlag(mapCube); mapCube.isFlipped = true; Debug.Log("Set Flag"); } else if (money >= flipcost) { ChangeMoney(-flipcost); mapCube.BuildNumber(mapCube); if (mapCube.isMine) { ChangeMine(-1); } } else { MineAudio.Play(); //提示钱不够 moneyAnimator.SetTrigger("Flicker"); } } else if (mapCube.isFlipped && mapCube.hasFlag && selectedTurretData != null && mapCube.turretGo == null)//翻,有旗 { //判定 //Cube确实是Mine if (mapCube.name.Equals("MapCubeM")) { //Buildbonus if (money >= selectedTurretData.cost) { ChangeMine(-1); ChangeMoney(-selectedTurretData.cost); mapCube.BonusTurret(selectedTurretData); } else { MineAudio.Play(); //提示钱不够 moneyAnimator.SetTrigger("Flicker"); } } else { //变叉 if (money >= selectedTurretData.cost) { ChangeMoney(-selectedTurretData.cost); mapCube.BuildWrong(mapCube); } else { MineAudio.Play(); //提示钱不够 moneyAnimator.SetTrigger("Flicker"); } } } else if (mapCube.isFlipped && !mapCube.isMine && !mapCube.hasFlag && selectedTurretData != null && mapCube.turretGo == null)//翻,无旗 { if (money >= selectedTurretData.cost) { ChangeMoney(-selectedTurretData.cost); mapCube.BuildTurret(selectedTurretData); } else { MineAudio.Play(); //提示钱不够 moneyAnimator.SetTrigger("Flicker"); } } else if (mapCube.turretGo != null) { // 升级处理 //if (mapCube.isUpgraded) //{ // ShowUpgradeUI(mapCube.transform.position, true); //} //else //{ // ShowUpgradeUI(mapCube.transform.position, false); //} if (mapCube == selectedMapCube && upgradeCanvas.activeInHierarchy) { StartCoroutine(HideUpgradeUI()); } else { dropMoneyText.text = "+$" + (int)((float)mapCube.turretData.cost * 0.8); ShowUpgradeUI(mapCube.transform.position, mapCube.isUpgraded); } selectedMapCube = mapCube; } } } } }