void Update() { if (!guiCamera.enabled) { //let the twin controll the beat return; } #if !UNITY_EDITOR && (UNITY_IPHONE || UNITY_ANDROID) if (Input.touchCount == 2 && Input.GetTouch(0).phase == TouchPhase.Moved && Input.GetTouch(1).phase == TouchPhase.Moved) { Vector2 curDist = Input.GetTouch(0).position - Input.GetTouch(1).position; //current distance between finger touches Vector2 oldDist = curDist - (Input.GetTouch(0).deltaPosition - Input.GetTouch(1).deltaPosition); float touchDelta = (curDist.magnitude - oldDist.magnitude) * Time.deltaTime; Vector2 screenPoint = Vector2.Lerp(Input.GetTouch(0).position, Input.GetTouch(1).position, 0.5f); #else if (Mathf.Abs(Input.GetAxis("Mouse ScrollWheel")) > 0f) { float touchDelta = Input.GetAxis("Mouse ScrollWheel"); Vector2 screenPoint = Input.mousePosition; #endif currentZoom = Mathf.Clamp(currentZoom + touchDelta * zoomFactor, minZoom, maxZoom); // Debug.Log("Current zoom: " + currentZoom); if (screenOffset.z == -1f) { screenPoint -= screenCenter; screenOffset = new Vector3(screenPoint.x * widthFactor, screenPoint.y * widthFactor, 0f); } SetMapZoomAndPosition(screenOffset, currentZoom); } else { screenOffset.z = -1f; } twinMap.SetPosition(cachedTransform.localPosition); }
void UpdateAvatar(bool centerMap = false) { // if (UserManager.Instance != null && User.CurrentUser.IsLogged) // { // UserManager.Instance.GetUserPictureProfile((avatar) => // { // if (avatar != null) { // mySprite.mainTexture = avatar; // } // else { // mySprite.mainTexture = defaultAvatar; // } // // TODO set texture on map // //TODO move texture on map // //User.CurrentUser.LastFinishedLvl; // // //TODO set score for finished level // //UserManager.Instance.SetScoreForLevel(); // }); // // CompanionsManager.Instance.RefreshLevelButtons(); // } // else { // mySprite.mainTexture = defaultAvatar; // } transform.parent.localPosition = CompanionsManager.Instance.avatarPosition; transform.parent.localScale = CompanionsManager.Instance.avatarScale; if (centerMap) { if (myMap == null) { myMap = transform.parent.parent.parent.GetComponent <MapPanelLimit>(); } Vector3 mapPos = -CompanionsManager.Instance.avatarButtonPosition * myMap.contents.localScale.x; mapPos.z = myMap.transform.localPosition.z; myMap.SetPosition(mapPos); } if (LoadLevelButton.newUnlockedLevel) { StartCoroutine(ResetNewUnlocked()); if (LoadLevelButton.maxLevels > LoadLevelButton.lastUnlockedLevel || (LoadLevelButton.maxLevels == LoadLevelButton.lastUnlockedLevel && UserManagerCloud.Instance.GetScoreForLevel(LoadLevelButton.lastUnlockedLevel) == 0)) { float duration = (CompanionsManager.Instance.avatarPosition - CompanionsManager.Instance.avatarOldPosition).magnitude / 100f; HOTween.From(transform.parent, duration, new TweenParms().Prop("localPosition", CompanionsManager.Instance.avatarOldPosition) .Ease(EaseType.Linear) .OnComplete(ActionOnMoveComplete) ); } else { LoadLevelButton.showNextLevel = false; CompanionsManager.Instance.gameEndFsm.SendEvent("AutoShow"); } } else if (LoadLevelButton.showBuyLives) { LoadLevelButton.showBuyLives = false; StartCoroutine(ShowBuyLives()); } }