| | |
| | | [RequireComponent(typeof(BoxCollider))] |
| | | public class TowerPlacementGridEndless : MonoBehaviour, IPlacementArea |
| | | { |
| | | public static float GRID_OPENCASH = 100; |
| | | public static float GRID_OPENCASH = 200; |
| | | |
| | | /// <summary> |
| | | /// Prefab used to visualise the grid. |
| | |
| | | // 血条位置的设定 |
| | | PreCalculateTowerBloodUi(); |
| | | |
| | | float[] gapArr = { 0.2f, 0.7f }; |
| | | float[] gapArr = { 0.5f, 1f }; |
| | | m_arrTGO = new EndlessTowerGridOpen[dimensions.x, dimensions.y]; |
| | | |
| | | GameObject container = GameObject.Find("BuyButtonContainer"); |
| | | TowerPlacementGridEndless.GRID_OPENCASH = 100; |
| | | TowerPlacementGridEndless.GRID_OPENCASH = 200; |
| | | //Debug.Log("修改了数值:" + TowerPlacementGridEndless.GRID_OPENCASH); |
| | | //float[] xup = { -0.6f, -0.3f, 0, 0.3f, 0.6f }; |
| | | for (int x = 0; x < dimensions.x; ++x) |
| | |
| | | if (m_arrGridType[x, y] != PlacementGridType.EGridWaitBuy) continue; |
| | | |
| | | GameObject buyButton = Instantiate(waitBuyBtnPrefab); |
| | | buyButton.transform.SetParent(container.transform); |
| | | buyButton.transform.SetParent(container.transform, false); |
| | | |
| | | Vector3 pos = buyButton.transform.position; |
| | | //pos.x = arrGridCentPos[x, y].x + (x - 2) * gapArr[3 - y] + xup[x]; |
| | |
| | | // } |
| | | pos.y = 30; |
| | | buyButton.transform.position = pos; |
| | | buyButton.transform.localRotation = Quaternion.identity; |
| | | buyButton.transform.localScale = Vector3.one; |
| | | |
| | | // 设置按钮对应的点击功能 |
| | | EndlessTowerGridOpen tgo = buyButton.GetComponent<EndlessTowerGridOpen>(); |
| | | if (tgo) |
| | | { |
| | | tgo.SetBuyBtnInfo(x, y, this); |
| | | tgo.cashText.SetText(TowerPlacementGrid.GRID_OPENCASH_SELF.ToString()); |
| | | tgo.cashText.SetText(TowerPlacementGridEndless.GRID_OPENCASH.ToString()); |
| | | m_arrTGO[x, y] = tgo; |
| | | } |
| | | } |
| | |
| | | |
| | | public void updateGridOpenCoin(int ix, int iy) |
| | | { |
| | | GRID_OPENCASH = Mathf.Floor(GRID_OPENCASH * 1.2f); |
| | | GRID_OPENCASH = Mathf.Floor(GRID_OPENCASH * 1.25f); |
| | | |
| | | for (int x = 0; x < dimensions.x; x++) |
| | | { |
| | |
| | | |
| | | for (int tx = 0; tx < dimensions.x; tx++) |
| | | { |
| | | m_arrGridType[tx, sy] = PlacementGridType.EGridWaitBuy; |
| | | // cx test |
| | | m_arrGridType[tx, sy - 1] = PlacementGridType.EGridWaitBuy; |
| | | m_arrGridType[tx, sy] = PlacementGridType.EGridOpen; |
| | | } |
| | | // 设置塔位默认开启,后面需要根据配置来 |
| | | m_arrGridType[2, 3] = PlacementGridType.EGridOpen; |
| | | // m_arrGridType[2, 3] = PlacementGridType.EGridOpen; |
| | | ++GameConfig.EndlessOpenAttackTowerCount; |
| | | } |
| | | |
| | |
| | | if (m_arrGridType[ix, y] == PlacementGridType.EGridOpen) |
| | | { |
| | | canPlace = true; |
| | | // for (int i = 0; i < allTowerP.Count; i++) |
| | | // { |
| | | // if (allTowerP[i].x == ix && allTowerP[i].y == y) |
| | | // { |
| | | // canPlace = false; |
| | | // break; |
| | | // } |
| | | // } |
| | | if (allTowerP != null) |
| | | { |
| | | for (int i = 0; i < allTowerP.Count; i++) |
| | | { |
| | | if (allTowerP[i].x == ix && allTowerP[i].y == y) |
| | | { |
| | | canPlace = false; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | m_Tiles[ix, y].CheckCanPlace(canPlace); |
| | | } |
| | | } |