public void SelectColorType() { switch (UIPopupList.current.value.Trim()) { case "无": myColorType = PubbleColorType.PUBBLE_EMPTY_TYPE; break; case "黄": myColorType = PubbleColorType.PUBBLE_YELLOW_TYPE; break; case "橙": myColorType = PubbleColorType.PUBBLE_ORANGE_TYPE; break; case "绿": myColorType = PubbleColorType.PUBBLE_GREEN_TYPE; break; case "紫": myColorType = PubbleColorType.PUBBLE_PURPLE_TYPE; break; case "蓝": myColorType = PubbleColorType.PUBBLE_BLUE_TYPE; break; case "青": myColorType = PubbleColorType.PUBBLE_CYAN_TYPE; break; case "红": myColorType = PubbleColorType.PUBBLE_RED_TYPE; break; case "气泡": //myColorType = PubbleColorType.PUBBLE_GAS_TYPE; break; case "石头": myColorType = PubbleColorType.PUBBLE_STONE_TYPE; break; default: break; } int indexPerfab = (int)myColorType; if (indexPerfab >= 0) { if (indexPerfab > ToolsManager.Instance.pubblePerfabs.Length - 1) { indexPerfab = ToolsManager.Instance.pubblePerfabs.Length - 1; } GameObject pubbleObject = Instantiate(ToolsManager.Instance.pubblePerfabs[indexPerfab]) as GameObject; pubbleObject.transform.parent = myObject.transform; pubbleObject.transform.localPosition = Vector3.zero; } }
/* * @brief 发射泡泡 * @param dir 发射的方向 * @desc 当点击了屏幕的时候,会调用该函数,在FixedUpdate执行发射 */ public void shootPubble(Vector3 dir) { shootType = markShootPubleObject.GetComponent<PubbleObject>().pubbleType; //做道具泡泡发射的检测 PlayUIScript.Instance.ChangePropLabelNum(shootType); //如果不是穿刺泡泡,则关闭运动学,便于检测 if (shootType != PubbleColorType.PUBBLE_CROSS_TYPE) { rigidbody.isKinematic = false; } else { //所有泡泡为运动学 碰撞器 与 运动学触发器 能够触发 触发器函数 GetComponent<SphereCollider>().isTrigger = true; } markMoveDirection = dir; isShooting = true; }
/* * @brief 统计当前可用的预备泡泡种类 * @parma type 传入类型,检测可用性以及是否存在,不存在且可用保存 */ void CalculatePrefabPubbleType(PubbleColorType pubbleType) { if (pubbleType < PubbleColorType.PUBBLE_AIR_TYPE && pubbleType > PubbleColorType.PUBBLE_EMPTY_TYPE) { //如果该类型符合预备标准,则判断当前数组是否存在 if (originPubbleArr.IndexOf(pubbleType) < 0) { //表示当前数组不存在该值 originPubbleArr.Add(pubbleType); } } }
/* * @brief 还原数据 * @desc 当发射完泡泡,进行检测的时候,达不到条件,则还原数据 */ public void ResetAllObjects() { //统计数值 置0 markNeedBurstAccount = 0; //还原发射泡泡的类型 markShootType = PubbleColorType.PUBBLE_EMPTY_TYPE; //重新update 页面上所有的泡泡 以及泡泡 绑定的脚本 UpdatePlayObjectsScriptsList(); //重置所有脚本 for (int i = 0; i < storageAllObjectScripts.Length; i++) { storageAllObjectScripts[i].ResetPubbleState(); } }
public void ChangePropLabelNum(PubbleColorType colorType) { switch (colorType) { case PubbleColorType.PUBBLE_CROSS_TYPE: crossNumber--; UserInstanse.GetInstance().stonePubble_Num = crossNumber; crossNumLabel.text = "" + crossNumber; break; case PubbleColorType.PUBBLE_FIRE_TYPE: fireNumber--; UserInstanse.GetInstance().firePubble_Num = fireNumber; fireNumLabel.text = "" + fireNumber; break; case PubbleColorType.PUBBLE_SNOW_TYPE: snowNumber--; UserInstanse.GetInstance().snowPubble_Num = snowNumber; snowNumLabel.text = "" + snowNumber; break; case PubbleColorType.PUBBLE_CRUSH_TYPE: crushNumber--; UserInstanse.GetInstance().stockPubble_Num = crushNumber; crushNumLabel.text = "" + crushNumber; break; default: break; } }
/* * @brief 点击了下面的道具泡泡的时候,将发射泡泡修改成道具泡泡 * @prama colorType 传入点击的道具泡泡类型 * @desc 成为道具泡泡之后,不可再替换,这个随策划吧 */ public void ExecuteEmissionPropPubble(PubbleColorType colorType) { //判断当前是否在发射之中,发射之中不准许 添加道具泡泡 if (GetShootState()) return; //同时判断当前 两个预备泡泡 有没有初始化完 if (!isInitFinish) return; //初始化道具泡泡,同时赋值给第一个预备泡泡 GameObject propObject = null; if ((int)colorType > (int)PubbleColorType.PUBBLE_RAINBOW_TYPE && (int)colorType <= (int)PubbleColorType.PUBBLE_CRUSH_TYPE) { propObject = GameObject.Instantiate(PlayLogic.Instance.pubbleKindPrefabs[(int)colorType - 1]) as GameObject; } if (propObject != null) { //如果存在这个道具泡泡 //标记为不可交换 markCanExChange = false; //销毁当前这个泡泡 DestroyObject(firstShootPubble); AssignObjectToFirstShootObject(propObject,false); } }