| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Runtime.InteropServices; |
| | | using Core.Utilities; |
| | | using KTGMGemClient; |
| | | using Microsoft.VisualBasic; |
| | | using TMPro.Examples; |
| | | using TowerDefense.Level; |
| | | using TowerDefense.UI.HUD; |
| | | using UnityEditor; |
| | | using UnityEngine; |
| | | using UnityEngine.Analytics; |
| | | using UnityEngine.UI; |
| | |
| | | /// 相应的界面指针传到塔防的数据结构内。 |
| | | /// </summary> |
| | | public GameObject towerBulletUIPrefab; |
| | | /// <summary> |
| | | /// 充能条对应的界面 |
| | | /// </summary> |
| | | public GameObject towerEnergyUIPrefab; |
| | | |
| | | /// <summary> |
| | | /// 等待购买开启对应按钮. |
| | | /// </summary> |
| | | public Button waitBuyBtnPrefab; |
| | | |
| | | // TEST CODE: |
| | | /// <summary> |
| | | /// 充能特效对应的Prefab. |
| | | /// </summary> |
| | | public ParticleSystem energyEffectPrefab; |
| | | |
| | | // TEST CODE TO DELETE: |
| | | public ParticleSystem TestParticle; |
| | | protected ParticleSystem PlayParticle; |
| | | protected Timer effectStopTimer; |
| | |
| | | /// </summary> |
| | | Vector2[] m_arrTowerBulletUIPos; |
| | | BulletUICtl[] arrTowerBulletUi; |
| | | EnergyUICtl[] arrTowerEnergyUi; |
| | | ParticleSystem[] arrTowerEnergyEffect; |
| | | |
| | | |
| | | /// <summary> |
| | |
| | | /// </summary> |
| | | /// <param name="x"></param> |
| | | /// <returns></returns> |
| | | public BulletUICtl GetBulletUICtl(int x) |
| | | public BulletUICtl GetBulletUICtl(int x, int y) |
| | | { |
| | | return this.arrTowerBulletUi[x]; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取对应位置的能量条界面指针. |
| | | /// </summary> |
| | | /// <param name="x"></param> |
| | | /// <returns></returns> |
| | | public EnergyUICtl GetEnergyUICtl(int x, int y) |
| | | { |
| | | return this.arrTowerEnergyUi[x]; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | } |
| | | } |
| | | |
| | | protected void partilceUpdate() |
| | | { |
| | | if (bTimerStart) |
| | | { |
| | | if (effectStopTimer.Tick(Time.deltaTime)) |
| | | { |
| | | bTimerStart = false; |
| | | effectStopTimer.Reset(); |
| | | } |
| | | } |
| | | |
| | | if (UnityEngine.Input.GetKeyDown(KeyCode.Q)) |
| | | { |
| | | this.PlayEnergyEffect(2, true); |
| | | return; |
| | | } |
| | | if (UnityEngine.Input.GetKeyDown(KeyCode.W)) |
| | | { |
| | | this.PlayEnergyEffect(2, false); |
| | | return; |
| | | } |
| | | |
| | | // TEST CODE TO DELETE: |
| | | if (PlayParticle != null) |
| | | { |
| | | |
| | | if (UnityEngine.Input.GetKeyDown(KeyCode.E)) |
| | | { |
| | | PlayParticle = Instantiate(TestParticle); |
| | | Vector3 tpos = this.transform.position; |
| | | tpos.y += 5.0f; |
| | | PlayParticle.transform.position = tpos; |
| | | |
| | | //Vector3 lookVec = Vector3.zero; |
| | | //lookVec.x = 1; |
| | | //PlayParticle.transform.LookAt(lookVec); |
| | | PlayParticle.Play(); |
| | | //effectStopTimer.SetTime(0.15f); |
| | | //bTimerStart = true; |
| | | } |
| | | if (UnityEngine.Input.GetKeyDown(KeyCode.F)) |
| | | { |
| | | PlayParticle.Stop(true, ParticleSystemStopBehavior.StopEmittingAndClear); |
| | | } |
| | | } |
| | | } |
| | | |
| | | void Update() |
| | | { |
| | | /* if (bTimerStart) |
| | | { |
| | | if (effectStopTimer.Tick(Time.deltaTime)) |
| | | { |
| | | bTimerStart = false; |
| | | effectStopTimer.Reset(); |
| | | } |
| | | } |
| | | |
| | | // TEST CODE TO DELETE: |
| | | if ( PlayParticle != null) |
| | | { |
| | | |
| | | if (UnityEngine.Input.GetKeyDown(KeyCode.E)) |
| | | { |
| | | PlayParticle = Instantiate(TestParticle); |
| | | PlayParticle.transform.position = this.transform.position; |
| | | Vector3 lookVec = Vector3.zero; |
| | | lookVec.x = 1; |
| | | PlayParticle.transform.LookAt(lookVec); |
| | | PlayParticle.Play(); |
| | | effectStopTimer.SetTime( 0.15f ); |
| | | bTimerStart = true; |
| | | } |
| | | if (UnityEngine.Input.GetKeyDown(KeyCode.F)) |
| | | { |
| | | PlayParticle.Stop(true, ParticleSystemStopBehavior.StopEmittingAndClear); |
| | | } |
| | | }*/ |
| | | // |
| | | // TEST CODE TO DELETE: |
| | | partilceUpdate(); |
| | | |
| | | if (m_arrCoinGenTime == null) return; |
| | | |
| | |
| | | |
| | | if (arrTowerBulletUi[x] != null) |
| | | arrTowerBulletUi[x].gameObject.SetActive(false); |
| | | |
| | | if (arrTowerEnergyUi[x] != null) |
| | | arrTowerEnergyUi[x].gameObject.SetActive(false); |
| | | |
| | | m_Tiles[x, y].SetTileType(PlacementGridType.EGridDestroyed); |
| | | |
| | |
| | | // 处理攻击塔位对应的血条 |
| | | m_arrTowerBulletUIPos = new Vector2[dimensions.x]; |
| | | arrTowerBulletUi = new BulletUICtl[dimensions.x]; |
| | | arrTowerEnergyUi = new EnergyUICtl[dimensions.x]; |
| | | arrTowerEnergyEffect = new ParticleSystem[dimensions.x]; |
| | | |
| | | for (int x = 0; x < dimensions.x; x++) |
| | | { |
| | | m_arrTowerBulletUIPos[x].x = m_arrGridCentUIPos[x, dy].x + m_fGridUISize/2.0f - 10; |
| | | m_arrTowerBulletUIPos[x].y = m_arrGridCentUIPos[x, dy].y; |
| | | |
| | | GameObject img = Instantiate(towerBulletUIPrefab); |
| | | |
| | | GameObject go = GameObject.Find("BattleMainUI"); |
| | | if (!go) continue; |
| | | Transform tp = go.GetComponent<Transform>(); |
| | | |
| | | GameObject img; |
| | | |
| | | img = Instantiate(towerBulletUIPrefab); |
| | | img.GetComponent<Transform>().SetParent(tp, true); |
| | | Vector3 tpos = img.transform.position; |
| | | tpos.x = m_arrTowerBulletUIPos[x].x; |
| | |
| | | BulletUICtl buc = img.GetComponent<BulletUICtl>(); |
| | | arrTowerBulletUi[x] = buc; |
| | | buc.gameObject.SetActive(false); |
| | | |
| | | // 把充能条也创建出来了. |
| | | img = Instantiate(towerEnergyUIPrefab); |
| | | img.GetComponent<Transform>().SetParent(tp, true); |
| | | tpos = img.transform.position; |
| | | tpos.x = m_arrTowerBulletUIPos[x].x; |
| | | tpos.y = m_arrTowerBulletUIPos[x].y; |
| | | img.transform.position = tpos; |
| | | |
| | | img.transform.SetAsFirstSibling(); |
| | | EnergyUICtl euc = img.GetComponent<EnergyUICtl>(); |
| | | arrTowerEnergyUi[x] = euc; |
| | | euc.gameObject.SetActive(false); |
| | | |
| | | // 设置播放特效对应的3D坐标: |
| | | Vector3 vpos = GridToWorld(new IntVector2(x, dy), new IntVector2(2, 1)); |
| | | vpos.x -= (gridSize / 2.0f); |
| | | vpos.y += 5.0f; |
| | | |
| | | arrTowerEnergyEffect[x] = Instantiate( energyEffectPrefab ); |
| | | arrTowerEnergyEffect[x].transform.position = vpos; |
| | | arrTowerEnergyEffect[x].Stop(); |
| | | } |
| | | |
| | | return; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 在指定的位置播放充能成功的特效. |
| | | /// </summary> |
| | | /// <param name="x"></param> |
| | | /// <param name="play">是播放还是停止播放</param> |
| | | public void PlayEnergyEffect( int x,bool play = true ) |
| | | { |
| | | if (!arrTowerEnergyEffect[x]) return; |
| | | if( play) |
| | | { |
| | | arrTowerEnergyEffect[x].Play(); |
| | | } |
| | | else |
| | | { |
| | | arrTowerEnergyEffect[x].Stop(); |
| | | } |
| | | return; |
| | | } |
| | | |
| | | |
| | | public void updateGridOpenCoin(int ix, int iy) |
| | | { |