| | |
| | | |
| | | private EnergyUICtl[,] arrTowerEnergyUi; |
| | | |
| | | private ParticleSystem[,] arrTowerEnergyEffect; |
| | | private FreezeBreath[,] arrTowerFreezeBreathUi; |
| | | |
| | | private GameObject[,] arrTowerEnergyEffect; |
| | | |
| | | /// <summary> |
| | | /// 水精灵充能满特效 |
| | | /// </summary> |
| | | private GameObject[,] arrTowerFreezeBreathEffect; |
| | | |
| | | /// <summary> |
| | | /// 充能特效对应的Prefab. |
| | | /// </summary> |
| | | public ParticleSystem energyEffectPrefab; |
| | | public GameObject energyEffectPrefab; |
| | | |
| | | /// <summary> |
| | | /// 此位置上塔对应的子弹充能Prefab.塔放置到当前的塔位后,如果是对应的塔防类型,需要把 |
| | |
| | | /// 充能条对应的界面 |
| | | /// </summary> |
| | | public GameObject towerEnergyUIPrefab; |
| | | |
| | | /// <summary> |
| | | /// 水精灵塔技能(冷冻气息)充能条 |
| | | /// </summary> |
| | | public GameObject FreezeBreathChargePrefab; |
| | | |
| | | /// <summary> |
| | | /// 水精灵塔充能条特效 |
| | | /// </summary> |
| | | public GameObject FreezeBreathChargeEffect; |
| | | |
| | | /// <summary> |
| | | /// Converts a location in world space into local grid coordinates. |
| | |
| | | return arrTowerEnergyUi[x, 3 - y]; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取水精灵对应位置的充能条 |
| | | /// </summary> |
| | | /// <param name="x"></param> |
| | | /// <param name="y"></param> |
| | | /// <returns></returns> |
| | | public FreezeBreath GetFreezeBreath(int x, int y) |
| | | { |
| | | return arrTowerFreezeBreathUi[x, 3 - y]; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取一个可以放置塔防的位置. |
| | |
| | | m_arrTowerBulletUIPos = new Vector2[dimensions.x, AttackRowNumbers]; |
| | | arrTowerBulletUi = new BulletUICtl[dimensions.x, AttackRowNumbers]; |
| | | arrTowerEnergyUi = new EnergyUICtl[dimensions.x, AttackRowNumbers]; |
| | | arrTowerEnergyEffect = new ParticleSystem[dimensions.x, AttackRowNumbers]; |
| | | arrTowerFreezeBreathUi = new FreezeBreath[dimensions.x, AttackRowNumbers]; |
| | | arrTowerEnergyEffect = new GameObject[dimensions.x, AttackRowNumbers]; |
| | | arrTowerFreezeBreathEffect = new GameObject[dimensions.x, AttackRowNumbers]; |
| | | |
| | | float[] gapArr = { 0.4f, 0.6f }; |
| | | |
| | |
| | | |
| | | arrTowerEnergyEffect[x, y] = Instantiate(energyEffectPrefab); |
| | | arrTowerEnergyEffect[x, y].transform.position = vpos; |
| | | arrTowerEnergyEffect[x, y].Stop(); |
| | | |
| | | // 创建水精灵充能条 |
| | | img = Instantiate(FreezeBreathChargePrefab); |
| | | img.transform.SetParent(container.transform); |
| | | tpos = img.transform.position; |
| | | tpos.x = m_arrTowerBulletUIPos[x, y].x + 4.4f + (x - 2) * gapArr[y]; |
| | | tpos.z = m_arrTowerBulletUIPos[x, y].y + 5f; |
| | | tpos.y = 30f; |
| | | img.transform.position = tpos; |
| | | img.transform.localScale = Vector3.one; |
| | | img.transform.localRotation = Quaternion.identity; |
| | | |
| | | FreezeBreath freezeBreath = img.GetComponent<FreezeBreath>(); |
| | | arrTowerFreezeBreathUi[x, y] = freezeBreath; |
| | | freezeBreath.gameObject.SetActive(false); |
| | | |
| | | arrTowerFreezeBreathEffect[x, y] = Instantiate(FreezeBreathChargeEffect); |
| | | arrTowerFreezeBreathEffect[x, y].transform.position = vpos; |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | if (!arrTowerEnergyEffect[x, dy]) return; |
| | | |
| | | ParticleSystem ps = arrTowerEnergyEffect[x, dy].GetComponent<ParticleSystem>(); |
| | | |
| | | if (ps == null) |
| | | ps = arrTowerEnergyEffect[x, dy].transform.GetChild(0).GetComponent<ParticleSystem>(); |
| | | |
| | | if (play) |
| | | { |
| | | if (!arrTowerEnergyEffect[x, dy].gameObject.activeSelf) |
| | | arrTowerEnergyEffect[x, dy].gameObject.SetActive(true); |
| | | arrTowerEnergyEffect[x, dy].Play(); |
| | | ps.Play(); |
| | | } |
| | | else |
| | | { |
| | | |
| | | arrTowerEnergyEffect[x, dy].Stop(); |
| | | ps.Stop(); |
| | | arrTowerEnergyEffect[x, dy].gameObject.SetActive(false); |
| | | } |
| | | } |
| | | |
| | | public void PlayFreezeBreathEffect(int x, int y, bool play = true) |
| | | { |
| | | int dy = dimensions.y - 1 - y; |
| | | |
| | | if (!arrTowerFreezeBreathEffect[x, dy]) return; |
| | | |
| | | ParticleSystem ps = arrTowerFreezeBreathEffect[x, dy].GetComponent<ParticleSystem>(); |
| | | |
| | | if (ps == null) |
| | | ps = arrTowerFreezeBreathEffect[x, dy].transform.GetChild(0).GetComponent<ParticleSystem>(); |
| | | |
| | | if (play) |
| | | { |
| | | if (!arrTowerFreezeBreathEffect[x, dy].gameObject.activeSelf) |
| | | arrTowerFreezeBreathEffect[x, dy].gameObject.SetActive(true); |
| | | ps.Play(); |
| | | } |
| | | else |
| | | { |
| | | ps.Stop(); |
| | | arrTowerFreezeBreathEffect[x, dy].gameObject.SetActive(false); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// Set collider's size and center |
| | | /// </summary> |