/// <summary> /// 取消暂停 /// </summary> public void cancelPause(int target = -1) { FishMaker.instant.isPause = false; fishPauseMask.transform.localScale = Vector3.zero; iTween.Resume(GameObject.Find("fishGroup"), true); pauseTime = 0; isSnow = false; GameObject.Find("bingDong").transform.Find("BBD").gameObject.SetActive(false); GameObject.Find("bingDong").transform.Find("BBDD").gameObject.SetActive(false); GameObject.Find("bingDong").transform.Find("BK").gameObject.SetActive(false); GameObject[] bingDongFish = GameObject.FindGameObjectsWithTag("Fish"); for (int i = 0; i < bingDongFish.Length; i++) { bingDongFish[i].GetComponent <Animator>().enabled = true; } GameObject bingDongLockFish = GameObject.FindGameObjectWithTag("lockFish"); if (bingDongLockFish != null) { bingDongLockFish.GetComponent <Animator>().enabled = true; } if (target == meiRenYuThreadDeal.gosWeiZhi) { WebButtonSendMessege.instant().skillOver("frozenFish"); } }
// Update is called once per frame void Update() { if (yuzhenPrefab != null && everyMakeOn) { //鱼阵结束yuzhenNew2(Clone) if ((yuzhenPrefab.name == "yuzhenNew1(Clone)" && yuzhenPrefab.transform.localPosition.x >= 6) || (yuzhenPrefab.name == "yuzhenNew2(Clone)" && yuzhenPrefab.transform.localPosition.x <= -12) || (yuzhenPrefab.name == "yuzhenNew3(Clone)" && (yuzhenPrefab.transform.Find("pos").position.x) >= -20f) || (yuzhenPrefab.name == "yuzhenNew4(Clone)" && (yuzhenPrefab.transform.Find("pos").position.x) >= 40f))//这儿注意数字 { Debug.Log("进来了。。。。。。。。。。。"); yuzhenFinish = true; contrall.instant().isCanClearFish = false; everyMakeOn = false; //yuzhenPrefab = null; } if (yuzhenStart) { //鱼阵开始 if (contrall.instant().isZhuJi) //如果是主机,则要发送征求信息 { WebButtonSendMessege.instant().fishArrayStartMove(yuzhenCard); //发送给服务器征求鱼阵的游动 } yuzhenStart = false; } } if (is20019) { deal20019(); is20019 = false; } }
/// <summary> /// 进入选择房间 /// </summary> /// <param name="index_c"></param> public void format(string _id, GameObject sender, int clickNum) { saveDate.startCenterPos = clickNum; GameObject areaScrollviewChild = areaScrollViewTransf.GetChild(areaScrollViewTransf.childCount - 1).gameObject; if (sender == areaScrollviewChild) { WebButtonSendMessege.instant().selectGameArea(_id); } }
/// <summary> /// 先点击按钮发送要制造子弹的消息,返回信息后才能开始把此子弹发射 /// </summary> void isCanFire() { //点击了鼠标左键, 并且没有点击到UI上 //**此处需要把背景的RaycastTarget去掉,否则IsPointerOverGameObject始终 = true if (ziDanFireTime > fireZiDanTimeMid && lastBulletFire) { if (meiRenYuThreadDeal.instant.yuzhenOpenFire)//鱼阵期间不让开火 { if (isAutoFire) { //Debug.Log("自动发炮"); ziDanFireTime = 0; // Debug.Log("自动发炮"); lastBulletFire = false; //上一个子弹发射没接收到服务器消息,禁止发射下一个子弹 fireTimeJiShi.isCanFire = true; WebButtonSendMessege.instant().openFire("20006", GunFollow.angle.ToString()); //每发射一次炮弹,给服务器传一次角度,发射的是跟鼠标的角度 } else if (Input.GetMouseButton(0)) { #if UNITY_IPHONE || UNITY_ANDROID if (IsPointerOverGameObject()) #else if (EventSystem.current.IsPointerOverGameObject()) #endif {// Debug.Log("当前触摸在UI上"); } else { //Debug.Log("实例化波纹"); //GameObject g = Instantiate(waveFinger, waveFingerParent.transform); //g.transform.position = Camera.main.ScreenToWorldPoint(Input.mousePosition); //Vector3 v = g.transform.position; //v.z = 0; //g.transform.position = v; ziDanFireTime = 0; lastBulletFire = false; //上一个子弹发射没接收到服务器消息,禁止发射下一个子弹 fireTimeJiShi.isCanFire = true; WebButtonSendMessege.instant().openFire("20006", GunFollow.angle.ToString()); //每发射一次炮弹,给服务器传一次角度,发射的是跟鼠标的角度 } } } } ziDanFireTime += Time.deltaTime; }
private void Update() { if (isBelongYuZhen)//属于鱼阵 { //if (fishArrayContral.instant.yuzhenFinish && yuzhenOne) //{ // if (contrall.instance.isZhuJi) // { // Debug.LogError("鱼阵里的鱼发送死亡" + this.id); // ClientSocket.instant().send("20010", id); // } // //WebButtonSendMessege.instant().fishDead(this.id);//鱼自然死亡发送消息给服务器 // yuzhenOne = false; //} } else { if (Send20010One) { nextDian = nextItem(guiJi.instant().guiJiDict[runPoint], this.transform.localPosition.x, this.transform.localPosition.y); } if (nextDian == guiJi.instant().guiJiDict[runPoint].Count - 1)//9是终点,且8也在屏幕外 { if (!contrall.instant().isCanClearFish) { Send20010One = false; nextDian = 100; //只发一次 if (contrall.instant().isZhuJi) //如果是主机则请求 { //Debug.Log(fishArrayContral.instant.everyMakeOn); if (!fishArrayContral.instant.everyMakeOn) //鱼阵期间不让发 { WebButtonSendMessege.instant().fishDead(this.id); //鱼自然死亡发送消息给服务器 } } } } } }
private void Update() { //网消失掉 if (i == 1 && web == null) { if (belongTarget == meiRenYuThreadDeal.gosWeiZhi) { //Debug.Log("对象"+belongTarget+"id......................"+id); WebButtonSendMessege.instant().bulletDie("20009", id, x.ToString(), y.ToString(), FishMaker.SaveNet[id]); i = 0; } } if (this.transform.localScale == Vector3.zero)//碰到鱼后,没收到返回信息,自动消除 { Invoke("bulletSelfDestroy", 2); } if (this.transform.localPosition.x < -12 || this.transform.localPosition.x > 12 || this.transform.localPosition.y < -7 || this.transform.localPosition.y > 7)//子弹出界 { Invoke("bulletSelfDestroy", 1); } }
void Start() { instant = this; snowParent = GameObject.Find("bingDong"); automaticFireMask = GameObject.Find("automaticFireMask"); automaticFire = GameObject.Find("automaticFire"); fishPauseMask = GameObject.Find("fishPauseMask"); autoLockMask = GameObject.Find("autoLockMask"); GameObject.Find("fishPause").GetComponent <Button>().onClick.AddListener(delegate() { if (!contrall.instant().isCanClearFish) { WebButtonSendMessege.instant().releaseSkill("frozenFish", meiRenYuThreadDeal.gosWeiZhi); } else { GameObject.Find("noBingDong").transform.localScale = Vector3.one; bingDongTime = true; } }); GameObject.Find("autoLock").GetComponent <Button>().onClick.AddListener(autoLockFish); GameObject.Find("automaticFire").GetComponent <Button>().onClick.AddListener(autoFire); GameObject.Find("automaticFireMask").GetComponent <Button>().onClick.AddListener(autoFire); }
/// <summary> /// 进入房间的人的信息,发给所有人 /// </summary> public void do20017(object o) { Debug.Log("收到20017"); joinUserId = ((JsonData)o)["userId"].ToString(); //添加用户到字典中,如果进入的是我自己,则不添加 if (((JsonData)o)["userId"].ToString() != httpView.id) { Debug.Log("收到200171"); GameController.gunShapes.Add(((JsonData)o)["userId"].ToString(), 0);//添加枪 for (int i = 0; i < userDict.Count; i++) { if (userDict[i] == null) { userDict[i] = ((JsonData)o)["userId"].ToString(); meiRenYuThreadDeal.instant.oGold = o; meiRenYuThreadDeal.instant.goldTarget = i; meiRenYuThreadDeal.instant.is20017 = true; break; } if (i == userDict.Count - 1) { userDict.Add(i + 1, ((JsonData)o)["userId"].ToString()); meiRenYuThreadDeal.instant.oGold = o; meiRenYuThreadDeal.instant.goldTarget = i + 1; meiRenYuThreadDeal.instant.is20017 = true; break; } } } if (instant().isZhuJi&& ((JsonData)o)["userId"].ToString() != httpView.id) //如果本机是主机并且进入房间的不是自己,则需要转发房间信息给进来的人 { Debug.Log("收到200172"); WebButtonSendMessege.instant().giveCurrentRoomMsg(); } }
void Update() { //yuZhenTime += Time.deltaTime; //if (yuZhenTime >= yuzhenTime1) //{ // if (contrall.instant().isZhuJi) // { // WebButtonSendMessege.instant().yuZhenTime(); // } // yuzhenTime1 += yuzhenDesign; //} if (GameController.Instance.isAutoLock) { if (LockTime >= needLockTime) { autoLockMask.transform.localScale = Vector3.zero; GameController.Instance.isAutoLock = false; GameController.Instance.isAutoFire = false; GameController.Instance.isXuanZhongFish = false; LockTime = 0; if (GameObject.Find("autoLockEffect(Clone)") != null) { Destroy(GameObject.Find("autoLockEffect(Clone)").gameObject); } automaticFire.transform.localScale = Vector3.one; automaticFireMask.transform.localScale = Vector3.zero; WebButtonSendMessege.instant().skillOver("autoLockFish", meiRenYuThreadDeal.gosWeiZhi); } autoLockMask.GetComponent <Image>().fillAmount = 1 - LockTime / needLockTime; LockTime += Time.deltaTime; } if (FishMaker.instant.isPause) { if (pauseTime >= needPauseTime) { cancelPause(meiRenYuThreadDeal.gosWeiZhi); } fishPauseMask.GetComponent <Image>().fillAmount = 1 - pauseTime / needPauseTime; pauseTime += Time.deltaTime; } if (bingDongTime) { noBingDong += Time.deltaTime; if (noBingDong >= 2) { GameObject.Find("noBingDong").transform.localScale = Vector3.zero; bingDongTime = false; noBingDong = 0; } } if (is20019Pause) { pause(); is20019Pause = false; } if (is20020CancelPause) { cancelPause(); is20020CancelPause = false; } //雪花效果 if (isSnow) { if (sonwTime == 0) { GameObject g = Instantiate(snow, snowParent.transform); int r = Random.Range(1, 7); if (r == 3) { g.transform.localScale = new Vector3(1.5f, 1.5f, 1.5f); } if (r == 5) { g.transform.localScale = new Vector3(2f, 2f, 2f); } } //sonwTime += Time.deltaTime; //if (sonwTime >= 0.2) //{ // sonwTime = 0; //} } }
/// <summary> /// 鱼的生成 /// </summary> /// <param name="_fishType">鱼类型</param> /// <param name="_id">鱼的ID</param> /// <param name="runPoint">鱼的轨迹</param> void MakeFishes(string _fishType, string _id, string _runPoint, int _nextDian, float _speed, bool _isHalfGoGame) { if (contrall.instant().isCanClearFish)//鱼阵开始后后面的鱼不再游动 { return; } //生成鱼的种类 GameObject fishObj = Instantiate(fishPrefabsDict[_fishType]); //if (meiRenYuThreadDeal.gosWeiZhi == 1) //{ // fishObj.transform.rotation = Quaternion.Euler(0,0,180); //} fishObj.transform.GetChild(0).GetComponent <SpriteRenderer>().sortingOrder = fishOrderLay; fishOrderLay++; if (fishOrderLay >= 90) { fishOrderLay = 0; } if (_isHalfGoGame)//如果是中途进入房间的 { fishObj.transform.localPosition = new Vector3(fish[_id].initialX, fish[_id].initialY, 90); } else { fishObj.transform.localPosition = new Vector3(guiJi.instant().guiJiDict[_runPoint][0].x, guiJi.instant().guiJiDict[_runPoint][0].y, 90);//赋予出生点,不设置有一个闪的过程 } //添加鱼对象 fishObj.GetComponent <FishAttr>().id = _id; fishObj.GetComponent <FishAttr>().fishType = _fishType; fishObj.GetComponent <FishAttr>().runPoint = _runPoint; fishObj.GetComponent <FishAttr>().nextDian = _nextDian; fishObj.GetComponent <FishAttr>().Speed = _speed; fishTarget.Add(_id, fishObj);//把鱼本身添加到字典中 fishObj.transform.SetParent(fishGroup, false); if (contrall.instant().isZhuJi) { if (isPause) { Debug.Log(4); FishMaker.fishTarget[_id].GetComponent <FishAttr>().isSend = true; CClient.ClientSocket.instant().send("20010", _id); //WebButtonSendMessege.instant().fishDead(_id); return;//如果冰冻了,产生直接消失 } } if (contrall.instant().isZhuJi) //如果是主机,则要发送征求信息 { WebButtonSendMessege.instant().fishStartMove(_id); //发送给服务器征求鱼的游动} } if (_isHalfGoGame) //只有中途进的那个瞬间才会直接游动 { if (contrall.instant().judgeIsMove.Contains(_id)) { guiJi.instant().startMove(fishTarget[_id].GetComponent <FishAttr>().runPoint, fishTarget[_id].GetComponent <FishAttr>().nextDian); //传入所需要的轨迹 //速度改变 iTween.MoveTo(fishTarget[_id].gameObject, iTween.Hash("path", guiJi.instant().waypoints, "speed", fishTarget[_id].gameObject.GetComponent <FishAttr>().Speed, "movetopath", false, "orienttopath", true, "looktime", 0.6, "easetype", "linear")); } } }
/// <summary> /// 自动判断鼠标射线检测 /// </summary> void mouseCheck() { if (isAutoLock) { if (Input.GetMouseButtonDown(0)) { Vector3 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition); RaycastHit2D hit = Physics2D.Raycast(new Vector2(mousePos.x, mousePos.y), Vector2.zero); if (hit.collider != null) { GameObject gameObj = hit.collider.gameObject; if (gameObj.tag == "Fish") { if (GameObject.FindGameObjectWithTag("lockFish") != null) { GameObject.FindGameObjectWithTag("lockFish").tag = "Fish"; } gameObj.tag = "lockFish"; lockFish = gameObj; isXuanZhongFish = true; isAutoFire = true; mainMeiRenYuContrall.instant.automaticFire.transform.localScale = Vector3.zero; mainMeiRenYuContrall.instant.automaticFireMask.transform.localScale = Vector3.one; //加上锁定标记 if (GameObject.Find("autoLockEffect(Clone)") != null) { Destroy(GameObject.Find("autoLockEffect(Clone)").gameObject); } Instantiate(autoLockEffect, gameObj.transform.parent.transform); WebButtonSendMessege.instant().releaseSkill("autoLockFish", meiRenYuThreadDeal.gosWeiZhi, gameObj.transform.parent.GetComponent <FishAttr>().id); } } } if (isXuanZhongFish) { if (contrall.instant().isCanClearFish) { if (lockFish == null || lockFish.transform.parent.transform.position.x > 9) { mainMeiRenYuContrall.instant.automaticFire.transform.localScale = Vector3.one; mainMeiRenYuContrall.instant.automaticFireMask.transform.localScale = Vector3.zero; isXuanZhongFish = false; isAutoFire = false; if (lockFish != null) { Destroy(lockFish.transform.parent.transform.Find("autoLockEffect(Clone)").gameObject); } } } else { if (lockFish == null || lockFish.transform.parent.GetComponent <FishAttr>().nextDian == (guiJi.instant().guiJiDict[lockFish.transform.parent.GetComponent <FishAttr>().runPoint].Count - 2)) { mainMeiRenYuContrall.instant.automaticFire.transform.localScale = Vector3.one; mainMeiRenYuContrall.instant.automaticFireMask.transform.localScale = Vector3.zero; isXuanZhongFish = false; isAutoFire = false; if (lockFish != null) { Destroy(lockFish.transform.parent.transform.Find("autoLockEffect(Clone)").gameObject); } } } } } }
/** * 调小枪的威力 * */ public void OnButtonDown() { buYuMusicContral.instant.allYinXiao[1].Play(); WebButtonSendMessege.instant().reduceButtleClass();//发送减炮等级 }
/** * 调大枪的威力 **/ public void OnButtonUp() { //buYuMusicContral.instant.allYinXiao[1].Play(); WebButtonSendMessege.instant().addButtleClass();//发送加炮等级 }
/// <summary> /// 返回到美人鱼选择区域 /// </summary> void returnToMeiRenYuArea() { //meiRenYuThreadDeal.instant.exitRoom(); WebButtonSendMessege.instant().exitRoom();//告诉服务器,退出房间 }