public void Respond() { NetworkClientUI.SendRespond(0); NetworkClientUI.ctl.GetComponent <CanvasGroup>().alpha = 1; NetworkClientUI.ctl.GetComponent <CanvasGroup>().blocksRaycasts = true; SceneManager.UnloadSceneAsync("Splitting Fall"); }
public void OnPointerDown() { NetworkClientUI.SendButtonInfo(Name); if (Name == "Fury 1") { if (mui.GetComponent <UI>().player.name == "Knight" && vrpy.GetComponent <Healthpoint>().fp >= (int)(vrpy.GetComponent <SkillInfo>().knightMFC[0] * 100)) { vrpy.GetComponent <Healthpoint>().fp -= (int)(vrpy.GetComponent <SkillInfo>().knightMFC[0] * 100); } else if (mui.GetComponent <UI>().player.name == "Archer" && vrpy.GetComponent <Healthpoint>().fp >= (int)(vrpy.GetComponent <SkillInfo>().archerMFC[0] * 100)) { vrpy.GetComponent <Healthpoint>().fp -= (int)(vrpy.GetComponent <SkillInfo>().archerMFC[0] * 100); } } if (Name == "Fury 2") { if (mui.GetComponent <UI>().player.name == "Knight" && vrpy.GetComponent <Healthpoint>().fp >= (int)(vrpy.GetComponent <SkillInfo>().knightMFC[1] * 100)) { vrpy.GetComponent <Healthpoint>().fp -= (int)(vrpy.GetComponent <SkillInfo>().knightMFC[1] * 100); } else if (mui.GetComponent <UI>().player.name == "Archer" && vrpy.GetComponent <Healthpoint>().fp >= (int)(vrpy.GetComponent <SkillInfo>().archerMFC[1] * 100)) { vrpy.GetComponent <Healthpoint>().fp -= (int)(vrpy.GetComponent <SkillInfo>().archerMFC[1] * 100); } } }
// Update is called once per frame void Update() { if (Input.GetKey(KeyCode.Space)) { NetworkClientUI.SendControllerInfo(4); } else if (Input.GetKey(KeyCode.UpArrow)) { NetworkClientUI.SendControllerInfo(0); } else if (Input.GetKey(KeyCode.DownArrow)) { NetworkClientUI.SendControllerInfo(1); } else if (Input.GetKey(KeyCode.LeftArrow)) { NetworkClientUI.SendControllerInfo(2); } else if (Input.GetKey(KeyCode.RightArrow)) { NetworkClientUI.SendControllerInfo(3); } else { NetworkClientUI.SendControllerInfo(-1); } }
public void Respond(float time) { NetworkClientUI.SendRespond(time); NetworkClientUI.ctl.GetComponent <CanvasGroup>().alpha = 1; NetworkClientUI.ctl.GetComponent <CanvasGroup>().blocksRaycasts = true; SceneManager.UnloadSceneAsync("Rifleshot"); gameObject.SetActive(false); }
//IDragHandler - OnDrag - Called on the drag object when a drag is happening public override void OnDrag(PointerEventData eventData) { Vector2 direction = eventData.position - joystickPosition; inputVector = (direction.magnitude > background.sizeDelta.x / 2f) ? direction.normalized : direction / (background.sizeDelta.x / 2f); handle.anchoredPosition = (inputVector * background.sizeDelta.x / 2f) * handleLimit; NetworkClientUI.SendControllerInfo(this.Horizontal, this.Vertical); }
public void Hitter(int pos) { if (AccelDodge.position == 0 || pos != AccelDodge.position) { hitScreen.SetActive(true); Invoke("ClearHitScreen", 0.5f); NetworkClientUI.SendUpdateHealth(hptake); } random = Random.Range(1, 4); }
void Update() { NetworkClientUI.SendJoystickInfo(variableJoystick.Vertical, variableJoystick.Horizontal, jump); timeCount += Time.deltaTime; if (timeCount > ThresholdTime) { timeCount = 0; jump = false; } }
public void Click() { x++; if (x >= limit) { if (isUseRespond) { NetworkClientUI.SendRespond(0); } GetComponent <Destroy>().DestroyButton2(); } }
//this is best to implement the Singleton pattern for MusicPlayer instance private void Awake() { if (_instance != null) { Destroy(gameObject); } else { _instance = this; DontDestroyOnLoad(gameObject); } }
void UpdateVirtualAxes(Vector3 value) { var delta = m_StartPos - value; delta.y = -delta.y; delta /= MovementRange; if (m_UseX) { m_HorizontalVirtualAxis.Update(-delta.x); } if (m_UseY) { m_VerticalVirtualAxis.Update(delta.y); } NetworkClientUI.SendControllerInfo(-delta.x, delta.y); }
void UpdateVirtualAxes(Vector3 value) { var delta = m_StartPos - value; delta.y = -delta.y; delta /= MovementRange; if (m_UseX) { m_HorizontalVirtualAxis.Update(-delta.x); } if (m_UseY) { m_VerticalVirtualAxis.Update(delta.y); } //Manda el mensaje al cliente NetworkClientUI.SendJoystickInfo(-delta.x, delta.y); }
// Update is called once per frame void Update() { if (gyroEnabled) { float rotX = gyro.attitude.x; float rotY = gyro.attitude.y; float rotZ = gyro.attitude.z; float rotW = gyro.attitude.w; Quaternion attr = new Quaternion(rotY, -rotX, rotZ, -rotW); float x = attr.eulerAngles.x; float y = attr.eulerAngles.y; float z = attr.eulerAngles.z; transform.localRotation = Quaternion.Euler(-y, x, -z); NetworkClientUI.SendGyroScopeInfo(gyro); } }
// Update is called once per frame void Update() { accelDir = Input.acceleration; if (NetworkClientUI.inGame) { if (vtpy.name == "Knight") { if (accelDir.sqrMagnitude >= 4.5f) { NetworkClientUI.SendRespond(0); vtpy.GetComponent <Healthpoint>().dbf = true; } else { NetworkClientUI.SendRespond(-1); vtpy.GetComponent <Healthpoint>().dbf = false; } } } }
public void SetDownState() { CrossPlatformInputManager.SetButtonDown(Name); NetworkClientUI.SendButtonInfo(Name); if (Name == "Fury 1") { if (mui.GetComponent <UI>().player.name == "Knight" && vrpy.GetComponent <Healthpoint>().fp >= (int)(vrpy.GetComponent <SkillInfo>().knightMFC[0] * 100)) { vrpy.GetComponent <Healthpoint>().fp -= (int)(vrpy.GetComponent <SkillInfo>().knightMFC[0] * 100); QuestCounter.furyUse++; } else if (mui.GetComponent <UI>().player.name == "Archer" && vrpy.GetComponent <Healthpoint>().fp >= (int)(vrpy.GetComponent <SkillInfo>().archerMFC[0] * 100)) { vrpy.GetComponent <Healthpoint>().fp -= (int)(vrpy.GetComponent <SkillInfo>().archerMFC[0] * 100); QuestCounter.furyUse++; } else if (mui.GetComponent <UI>().player.name == "Warchief" && vrpy.GetComponent <Healthpoint>().fp >= (int)(vrpy.GetComponent <SkillInfo>().warchiefMFC[0] * 100)) { vrpy.GetComponent <Healthpoint>().fp -= (int)(vrpy.GetComponent <SkillInfo>().warchiefMFC[0] * 100); QuestCounter.furyUse++; } else if (mui.GetComponent <UI>().player.name == "Berserker" && vrpy.GetComponent <Healthpoint>().fp >= (int)(vrpy.GetComponent <SkillInfo>().berserkerMFC[0] * 100)) { vrpy.GetComponent <Healthpoint>().fp -= (int)(vrpy.GetComponent <SkillInfo>().berserkerMFC[0] * 100); QuestCounter.furyUse++; } } else if (Name == "Fury 2") { if (mui.GetComponent <UI>().player.name == "Knight" && vrpy.GetComponent <Healthpoint>().fp >= (int)(vrpy.GetComponent <SkillInfo>().knightMFC[1] * 100)) { vrpy.GetComponent <Healthpoint>().fp -= (int)(vrpy.GetComponent <SkillInfo>().knightMFC[1] * 100); QuestCounter.furyUse++; } else if (mui.GetComponent <UI>().player.name == "Archer" && vrpy.GetComponent <Healthpoint>().fp >= (int)(vrpy.GetComponent <SkillInfo>().archerMFC[1] * 100)) { vrpy.GetComponent <Healthpoint>().fp -= (int)(vrpy.GetComponent <SkillInfo>().archerMFC[1] * 100); QuestCounter.furyUse++; } else if (mui.GetComponent <UI>().player.name == "Warchief" && vrpy.GetComponent <Healthpoint>().fp >= (int)(vrpy.GetComponent <SkillInfo>().warchiefMFC[1] * 100)) { vrpy.GetComponent <Healthpoint>().fp -= (int)(vrpy.GetComponent <SkillInfo>().warchiefMFC[1] * 100); QuestCounter.furyUse++; } else if (mui.GetComponent <UI>().player.name == "Berserker") { } } else if (Name == "Fury 3") { if (mui.GetComponent <UI>().player.name == "Knight") { } else if (mui.GetComponent <UI>().player.name == "Archer" && vrpy.GetComponent <Healthpoint>().fp >= (int)(vrpy.GetComponent <SkillInfo>().archerMFC[2] * 100)) { vrpy.GetComponent <Healthpoint>().fp -= (int)(vrpy.GetComponent <SkillInfo>().archerMFC[2] * 100); QuestCounter.furyUse++; } else if (mui.GetComponent <UI>().player.name == "Warchief" && vrpy.GetComponent <Healthpoint>().fp >= (int)(vrpy.GetComponent <SkillInfo>().warchiefMFC[2] * 100)) { vrpy.GetComponent <Healthpoint>().fp -= (int)(vrpy.GetComponent <SkillInfo>().warchiefMFC[2] * 100); QuestCounter.furyUse++; } else if (mui.GetComponent <UI>().player.name == "Berserker" && vrpy.GetComponent <Healthpoint>().fp >= (int)(vrpy.GetComponent <SkillInfo>().berserkerMFC[2] * 100)) { vrpy.GetComponent <Healthpoint>().fp -= (int)(vrpy.GetComponent <SkillInfo>().berserkerMFC[2] * 100); QuestCounter.furyUse++; } } else if (Name == "Skill 1") { if (mui.GetComponent <UI>().player.name == "Knight" && vrpy.GetComponent <SkillInfo>().knightCD[0, 0] == vrpy.GetComponent <SkillInfo>().knightCD[0, 1]) { vrpy.GetComponent <SkillInfo>().knightCD[0, 0] = 0; QuestCounter.spellUse++; } else if (mui.GetComponent <UI>().player.name == "Archer" && vrpy.GetComponent <SkillInfo>().archerCD[0, 0] == vrpy.GetComponent <SkillInfo>().archerCD[0, 1]) { vrpy.GetComponent <SkillInfo>().archerCD[0, 0] = 0; QuestCounter.spellUse++; } else if (mui.GetComponent <UI>().player.name == "Warchief" && vrpy.GetComponent <SkillInfo>().warchiefCD[0, 0] == vrpy.GetComponent <SkillInfo>().warchiefCD[0, 1]) { vrpy.GetComponent <SkillInfo>().warchiefCD[0, 0] = 0; QuestCounter.spellUse++; } else if (mui.GetComponent <UI>().player.name == "Berserker" && vrpy.GetComponent <SkillInfo>().berserkerCD[0, 0] == vrpy.GetComponent <SkillInfo>().berserkerCD[0, 1]) { vrpy.GetComponent <SkillInfo>().berserkerCD[0, 0] = 0; QuestCounter.spellUse++; } } else if (Name == "Skill 2") { if (mui.GetComponent <UI>().player.name == "Knight" && vrpy.GetComponent <SkillInfo>().knightCD[1, 0] == vrpy.GetComponent <SkillInfo>().knightCD[1, 1]) { vrpy.GetComponent <SkillInfo>().knightCD[1, 0] = 0; QuestCounter.spellUse++; } else if (mui.GetComponent <UI>().player.name == "Archer" && vrpy.GetComponent <SkillInfo>().archerCD[1, 0] == vrpy.GetComponent <SkillInfo>().archerCD[1, 1]) { vrpy.GetComponent <SkillInfo>().archerCD[1, 0] = 0; QuestCounter.spellUse++; } else if (mui.GetComponent <UI>().player.name == "Warchief" && vrpy.GetComponent <SkillInfo>().warchiefCD[1, 0] == vrpy.GetComponent <SkillInfo>().warchiefCD[1, 1]) { vrpy.GetComponent <SkillInfo>().warchiefCD[1, 0] = 0; QuestCounter.spellUse++; } else if (mui.GetComponent <UI>().player.name == "Berserker" && vrpy.GetComponent <SkillInfo>().berserkerCD[1, 0] == vrpy.GetComponent <SkillInfo>().berserkerCD[1, 1]) { vrpy.GetComponent <SkillInfo>().berserkerCD[1, 0] = 0; QuestCounter.spellUse++; } } else if (Name == "Skill 3") { if (mui.GetComponent <UI>().player.name == "Knight" && vrpy.GetComponent <SkillInfo>().knightCD[2, 0] == vrpy.GetComponent <SkillInfo>().knightCD[2, 1]) { vrpy.GetComponent <SkillInfo>().knightCD[2, 0] = 0; QuestCounter.spellUse++; } else if (mui.GetComponent <UI>().player.name == "Archer" && vrpy.GetComponent <SkillInfo>().archerCD[2, 0] == vrpy.GetComponent <SkillInfo>().archerCD[2, 1]) { vrpy.GetComponent <SkillInfo>().archerCD[2, 0] = 0; QuestCounter.spellUse++; } else if (mui.GetComponent <UI>().player.name == "Warchief" && vrpy.GetComponent <SkillInfo>().warchiefCD[2, 0] == vrpy.GetComponent <SkillInfo>().warchiefCD[2, 1]) { vrpy.GetComponent <VirturePlayer>().warchiefSkill3.SetActive(true); vrpy.GetComponent <SkillInfo>().warchiefCD[2, 0] = 0; QuestCounter.spellUse++; } else if (mui.GetComponent <UI>().player.name == "Berserker" && vrpy.GetComponent <SkillInfo>().berserkerCD[2, 0] == vrpy.GetComponent <SkillInfo>().berserkerCD[2, 1]) { vrpy.GetComponent <SkillInfo>().berserkerCD[2, 0] = 0; QuestCounter.spellUse++; } } else if (Name == "Trail") { if (mui.GetComponent <UI>().player.name == "Knight" && vrpy.GetComponent <SkillInfo>().knightCD[3, 0] == vrpy.GetComponent <SkillInfo>().knightCD[3, 1]) { vrpy.GetComponent <SkillInfo>().knightCD[3, 0] = 0; vrpy.GetComponent <SkillInfo>().knightBuff[6, 0] = 0; QuestCounter.trailUse++; } else if (mui.GetComponent <UI>().player.name == "Archer" && vrpy.GetComponent <SkillInfo>().archerCD[3, 0] == vrpy.GetComponent <SkillInfo>().archerCD[3, 1]) { vrpy.GetComponent <SkillInfo>().archerCD[3, 0] = 0; vrpy.GetComponent <SkillInfo>().archerBuff[6, 0] = 0; if (mui.GetComponent <UI>().isReverse) { mui.GetComponent <UI>().isReverse = false; } else { mui.GetComponent <UI>().isReverse = true; } QuestCounter.trailUse++; } else if (mui.GetComponent <UI>().player.name == "Warchief" && vrpy.GetComponent <SkillInfo>().warchiefCD[3, 0] == vrpy.GetComponent <SkillInfo>().warchiefCD[3, 1]) { vrpy.GetComponent <SkillInfo>().warchiefCD[3, 0] = 0; vrpy.GetComponent <SkillInfo>().warchiefBuff[6, 0] = 0; QuestCounter.trailUse++; } else if (mui.GetComponent <UI>().player.name == "Berserker" && vrpy.GetComponent <SkillInfo>().berserkerCD[3, 0] == vrpy.GetComponent <SkillInfo>().berserkerCD[3, 1]) { vrpy.GetComponent <SkillInfo>().berserkerCD[3, 0] = 0; vrpy.GetComponent <SkillInfo>().berserkerBuff[6, 0] = 0; QuestCounter.trailUse++; } } }
// Update is called once per frame void Update() { //COUNTER DOUBLE CLICK if (!disable) { if (isCounting) { timer -= Time.deltaTime; } if (timer <= 0) { isCounting = false; timer = 0.5f; } } else { distime -= Time.deltaTime; } if (distime <= 0) { distime = 0.75f; disable = false; } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //CONTROL UI if (isReverse) { for (int i = 0; i < UISLskill.Length - 1; i++) { UISLskill[i].SetActive(true); } } else { for (int i = 0; i < UISLskill.Length - 1; i++) { UISLskill[i].SetActive(false); } } if (player.name == "Knight") { //CHECK GUAGE for (int i = 0; i < 3; i++) { if (player.GetComponent <Healthpoint>().fp >= player.GetComponent <SkillInfo>().knightMFC[i] * 100) { UIskill[i].sprite = knightNM[i]; } else { UIskill[i].sprite = knightGS[i]; } } for (int j = 0; j < 3; j++) { if (player.GetComponent <Healthpoint>().mp >= player.GetComponent <SkillInfo>().knightMFC[j + 3] * 100 && player.GetComponent <SkillInfo>().knightCD[j, 0] >= player.GetComponent <SkillInfo>().knightCD[j, 1]) { UIskill[j + 3].sprite = knightNM[j + 3]; } else { UIskill[j + 3].sprite = knightGS[j + 3]; } } if (player.GetComponent <SkillInfo>().knightCD[3, 0] >= player.GetComponent <SkillInfo>().knightCD[3, 1]) { UIskill[6].sprite = knightNM[6]; } else { UIskill[6].sprite = knightGS[6]; } //CHECK COOLDOWN for (int k = 0; k < 4; k++) { if (player.GetComponent <SkillInfo>().knightCD[k, 0] < player.GetComponent <SkillInfo>().knightCD[k, 1]) { UICDskill[k].SetActive(true); } else { UICDskill[k].SetActive(false); } CDTime[k].text = (player.GetComponent <SkillInfo>().knightCD[k, 1] - player.GetComponent <SkillInfo>().knightCD[k, 0]).ToString(); } } else if (player.name == "Archer") { //CHECK GUAGE for (int i = 0; i < 3; i++) { if (player.GetComponent <Healthpoint>().fp >= player.GetComponent <SkillInfo>().archerMFC[i] * 100) { UIskill[i].sprite = archerNM[i]; } else { UIskill[i].sprite = archerGS[i]; } } for (int j = 0; j < 3; j++) { if (player.GetComponent <Healthpoint>().mp >= player.GetComponent <SkillInfo>().archerMFC[j + 3] * 100 && player.GetComponent <SkillInfo>().archerCD[j, 0] >= player.GetComponent <SkillInfo>().archerCD[j, 1]) { UIskill[j + 3].sprite = archerNM[j + 3]; } else { UIskill[j + 3].sprite = archerGS[j + 3]; } } if (player.GetComponent <SkillInfo>().archerCD[3, 0] >= player.GetComponent <SkillInfo>().archerCD[3, 1]) { UIskill[6].sprite = archerNM[6]; } else { UIskill[6].sprite = archerGS[6]; } //CHECK COOLDOWN for (int k = 0; k < 4; k++) { if (player.GetComponent <SkillInfo>().archerCD[k, 0] < player.GetComponent <SkillInfo>().archerCD[k, 1]) { UICDskill[k].SetActive(true); } else { UICDskill[k].SetActive(false); } CDTime[k].text = (player.GetComponent <SkillInfo>().archerCD[k, 1] - player.GetComponent <SkillInfo>().archerCD[k, 0]).ToString(); } } else if (player.name == "Warchief") { //CHECK GUAGE for (int i = 0; i < 3; i++) { if (player.GetComponent <Healthpoint>().fp >= player.GetComponent <SkillInfo>().warchiefMFC[i] * 100) { UIskill[i].sprite = warchiefNM[i]; } else { UIskill[i].sprite = warchiefGS[i]; } } for (int j = 0; j < 3; j++) { if (player.GetComponent <Healthpoint>().mp >= player.GetComponent <SkillInfo>().warchiefMFC[j + 3] * 100 && player.GetComponent <SkillInfo>().warchiefCD[j, 0] >= player.GetComponent <SkillInfo>().warchiefCD[j, 1]) { UIskill[j + 3].sprite = warchiefNM[j + 3]; } else { UIskill[j + 3].sprite = warchiefGS[j + 3]; } } if (player.GetComponent <SkillInfo>().warchiefCD[3, 0] >= player.GetComponent <SkillInfo>().warchiefCD[3, 1]) { UIskill[6].sprite = warchiefNM[6]; } else { UIskill[6].sprite = warchiefGS[6]; } //CHECK COOLDOWN for (int k = 0; k < 4; k++) { if (player.GetComponent <SkillInfo>().warchiefCD[k, 0] < player.GetComponent <SkillInfo>().warchiefCD[k, 1]) { UICDskill[k].SetActive(true); } else { UICDskill[k].SetActive(false); } CDTime[k].text = (player.GetComponent <SkillInfo>().warchiefCD[k, 1] - player.GetComponent <SkillInfo>().warchiefCD[k, 0]).ToString(); } } else if (player.name == "Berserker") { //CHECK GUAGE for (int i = 0; i < 3; i++) { if (player.GetComponent <Healthpoint>().fp >= player.GetComponent <SkillInfo>().berserkerMFC[i] * 100) { UIskill[i].sprite = berserkerNM[i]; } else { UIskill[i].sprite = berserkerGS[i]; } } for (int j = 0; j < 3; j++) { if (player.GetComponent <Healthpoint>().mp >= player.GetComponent <SkillInfo>().berserkerMFC[j + 3] * 100 && player.GetComponent <SkillInfo>().berserkerCD[j, 0] >= player.GetComponent <SkillInfo>().berserkerCD[j, 1]) { UIskill[j + 3].sprite = berserkerNM[j + 3]; } else { UIskill[j + 3].sprite = berserkerGS[j + 3]; } } if (player.GetComponent <SkillInfo>().berserkerCD[3, 0] >= player.GetComponent <SkillInfo>().berserkerCD[3, 1]) { UIskill[6].sprite = berserkerNM[6]; } else { UIskill[6].sprite = berserkerGS[6]; } //CHECK COOLDOWN for (int k = 0; k < 4; k++) { if (player.GetComponent <SkillInfo>().berserkerCD[k, 0] < player.GetComponent <SkillInfo>().berserkerCD[k, 1]) { UICDskill[k].SetActive(true); } else { UICDskill[k].SetActive(false); } CDTime[k].text = (player.GetComponent <SkillInfo>().berserkerCD[k, 1] - player.GetComponent <SkillInfo>().berserkerCD[k, 0]).ToString(); } } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //STATUS UI if (death) { death_b.SetActive(true); } else { death_b.SetActive(false); } if (status != null) { if (status == "Hack") { sts_b[int.Parse(etc) - 1].SetActive(true); joystick.SetActive(false); NetworkClientUI.SendJoystickInfo(0, 0); } else if (status == "Butch") { if (etc == "0") { NetworkClientUI.SceneAdditive("Butch"); } else if (etc == "1") { NetworkClientUI.SceneSubitive("Butch"); } } //Handheld.Vibrate(); //FOR MOBILE status = etc = null; } }
// Update is called once per frame void Update() { if (configBtnCoolDown > 0) { configBtnCoolDown--; } else if (configBtnCoolDown < 0) { configBtnCoolDown = 0; } if (swapBtnCooldown > 0) { swapBtnCooldown--; } else if (swapBtnCooldown < 0) { swapBtnCooldown = 0; } if (Input.touchCount > 0) { if (configuring == false) { bool dropbtnPressed = false; for (int i = 0; i < Input.touchCount; i++) { //觸碰configbtn if (Vector2.Distance(Input.touches[i].position, ConfigBtn.transform.position) < Screen.width / 10) { setconfig(); return; } //觸碰點到上下左右controller的向量 Vector2 dir = new Vector2((Input.touches[i].position.x - controller.transform.position.x), Input.touches[i].position.y - controller.transform.position.y); //觸碰點離放炸彈按鈕的距離 if (Vector2.Distance(Input.touches[i].position, new Vector2(dropBomb.transform.position.x, dropBomb.transform.position.y)) < Screen.width / 10) { dropbtnPressed = true; } //觸碰離上下左右太晚就break if ((dir.magnitude > Screen.height / 3) || (dir.magnitude > Screen.width / 3)) { break; } dir.Normalize(); //根據公式算出點即是上下左右何者 float angle = 0; if (dir.x < 0) { angle = 270 - (Mathf.Atan(dir.y / -dir.x) * Mathf.Rad2Deg); } else { angle = 90 + (Mathf.Atan(dir.y / dir.x) * Mathf.Rad2Deg); } if ((angle <= 45.0f && angle >= 0.0f) || (angle >= 315.0f && angle <= 360.0f)) { activeBtn[1] = true; activeBtn[0] = false; activeBtn[2] = false; activeBtn[3] = false; } else if (angle >= 45 && angle < 135) { activeBtn[3] = true; activeBtn[0] = false; activeBtn[2] = false; activeBtn[1] = false; } else if (angle >= 135 && angle < 225) { activeBtn[0] = true; activeBtn[1] = false; activeBtn[2] = false; activeBtn[3] = false; } else if (angle >= 225 && angle < 315) { activeBtn[2] = true; activeBtn[0] = false; activeBtn[1] = false; activeBtn[3] = false; } } activeBtn[4] = dropbtnPressed; for (int i = 4; i >= 0; i--) { if (activeBtn[i] == true) { NetworkClientUI.SendControllerInfo(i); return; } } } else { for (int i = 0; i < Input.touchCount; i++) { //觸碰configbtn if (Vector2.Distance(Input.touches[i].position, ConfigBtn.transform.position) < Screen.width / 20) { setconfig(); return; } //左右交換按鈕 if (Vector2.Distance(Input.touches[i].position, swapBtn.transform.position) < Screen.width / 20) { swap(); return; } //touch在螢幕左邊 if (Input.touches[i].position.x < Screen.width / 2) { //控制上下左右的在左邊 if (controllOnLeft == true) { controller.transform.position = Input.touches[i].position; } //控制上下左右的在右邊 else { dropBomb.transform.position = Input.touches[i].position; } } //touch在螢幕右邊 else { // 控制上下左右的在左邊 if (controllOnLeft == true) { dropBomb.transform.position = Input.touches[i].position; } //控制上下左右的在右邊 else { controller.transform.position = Input.touches[i].position; } } } } } else { for (int i = 4; i >= 0; i--) { activeBtn[i] = false; } NetworkClientUI.SendControllerInfo(-1); } }