public void ChangeOwnership(int ID) { IInteractable interactable = InteractableFactory.Instance.GetInteractable(ID); InteractableVisible visible = interactable.GetComponent <InteractableVisible>(); if (visible.visiblePlayer == VisiblePlayer.PLAYER_1) { visible.visiblePlayer = VisiblePlayer.PLAYER_2; } else if (visible.visiblePlayer == VisiblePlayer.PLAYER_2) { visible.visiblePlayer = VisiblePlayer.PLAYER_1; } visible.recheckVisible(); GetComponent <PickingThings>().toPickUp = null; GameObject endChecker = GameObject.Find("EndChecker"); if (endChecker != null) { EndChecker endCheckerScript = endChecker.GetComponent <EndChecker>(); if (endCheckerScript.isEnd()) { endCheckerScript.endPopup.SetActive(true); } } }
void Mirror() { if (!mirrorNowX && EndChecker.EndRight(transform.position.x)) { transform.rotation = Quaternion.Euler(0.0f, 0.0f, 180.0f - transform.localEulerAngles.z); if (mirrorSpeedChange != 0) { moveSpeed *= mirrorSpeedChange; } mirrorNowX = true; } else if (mirrorNowX && !EndChecker.EndRight(transform.position.x)) { mirrorNowX = false; } if (!mirrorNowY && (EndChecker.EndTop(transform.position.y) || EndChecker.EndBottom(transform.position.y))) { transform.rotation = Quaternion.Euler(0.0f, 0.0f, -transform.localEulerAngles.z); if (mirrorSpeedChange != 0) { moveSpeed *= mirrorSpeedChange; } mirrorNowY = true; } else if (mirrorNowY && !EndChecker.EndTop(transform.position.y) && !EndChecker.EndBottom(transform.position.y)) { mirrorNowY = false; } }
void Destroy() { if (EndChecker.EndLeft(transform.position.x + destroyWait)) { Destroy(gameObject); } if (!mirror && (EndChecker.EndRight(transform.position.x - destroyWait) || EndChecker.EndTop(transform.position.y - destroyWait) || EndChecker.EndBottom(transform.position.y + destroyWait))) { Destroy(gameObject); } }
void Move() { Vector2 afterPos = playerTouchState.beforePos + (playerTouchState.afterTouchPos - playerTouchState.beforeTouchPos); transform.position = afterPos; if (EndChecker.EndRight(transform.position.x + moveRestRight)) { transform.position = new Vector2(EndChecker.endRight - moveRestRight, transform.position.y); } else if (EndChecker.EndLeft(transform.position.x - moveRestOther)) { transform.position = new Vector2(EndChecker.endLeft + moveRestOther, transform.position.y); } if (EndChecker.EndTop(transform.position.y + moveRestOther)) { transform.position = new Vector2(transform.position.x, EndChecker.endTop - moveRestOther); } else if (EndChecker.EndBottom(transform.position.y - moveRestOther)) { transform.position = new Vector2(transform.position.x, EndChecker.endBottom + moveRestOther); } }