public void ShowRememberSendScore() { titleText.text = LanguageManager.Instance.GetTextValue("ui.label.remember"); lastName = PlayerPrefs.GetString("name", ""); specialThanksContentText.text = LanguageManager.Instance.GetTextValue("ui.label.remembersendscore"); AnalyticsSender.SendCustomAnalitycs("rememberSendScore", new Dictionary <string, object> { { "name", lastName } }); OpenWindow(GameManager.instance.EnableInput); }
public void ShowSpecialMention() { titleText.text = LanguageManager.Instance.GetTextValue("ui.label.specialthaks"); lastName = PlayerPrefs.GetString("name", ""); specialThanksContentText.text = LanguageManager.Instance.GetTextValue("ui.label.specialthankscontent").Replace("#username", lastName); AnalyticsSender.SendCustomAnalitycs("mentionShowed", new Dictionary <string, object> { { "name", lastName } }); OpenWindow(GameManager.instance.EnableInput); }
void BeginGame() { AnalyticsSender.SendCustomAnalitycs("gameStart", new Dictionary <string, object>()); //ResetGame (); spawner.SpawnPin(); if (OnBeginGame != null) { OnBeginGame(); } EnableInput(); }
public void EndTutorial() { currentTutorialStep = TutorialStep.END; PlayerPrefs.SetInt("tutorialVisto", 1); GameManager.instance.currentGamePlayState = GamePlayState.Normal; GameManager.instance.rotator.OnPinPinned -= HandleOnPinPinned; GameManager.instance.rotator.OnCompleteRotation -= HandleCompleteRotation; GameManager.instance.rotator.RotationSpeed = Rotator.INITIAL_SPEED; tutorialWrapper.SetActive(false); AnalyticsSender.SendCustomAnalitycs("tutorialEnd", new Dictionary <string, object>()); //Debug.Log ("Tutoral End"); }
public void CancelSendScore() { AnalyticsSender.SendCustomAnalitycs("scoreNotSend", new Dictionary <string, object> { { "score", GameManager.instance.Score }, { "nameUsedLastTime", lastName } }); if (UnityEngine.Random.Range(0, 2) == 0) { CloseWindow(SpecialThanksScreen.Instance.ShowRememberSendScore); } else { CloseWindow(); } }
public void GameOver() { if (isGameOver) { return; } rotator.enabled = false; spawner.enabled = false; isGameOver = true; SetGameState(GameState.GameOver); AnalyticsSender.SendCustomAnalitycs("gameOver", new Dictionary <string, object> { { "score", Score }, { "pinsCount", spawner.pinsCount } }); }
void SendScoreToBBDD(int result) { lastName = nameField.text; PlayerPrefs.SetString("name", lastName); FirebaseDBManager.instance.AddNewHighscore(new ScoreEntry(lastName, GameManager.instance.Score)); AnalyticsSender.SendCustomAnalitycs("scoreSended", new Dictionary <string, object> { { "score", GameManager.instance.Score }, { "name", lastName } }); //TODO /* * else { * Ventana modal avisando de que viendo videos colaboras a que mas juegos gratuitos como este sean creados. * } */ // Si no hemos mostrado la mención especial bool specialMentionShowed = PlayerPrefs.GetInt("specialMentionShowed", 0) == 1; bool showMention; if (!specialMentionShowed) { //if (lastName == "Pako") // showMention = true; //else showMention = UnityEngine.Random.Range(0, 10) == 0; } else { showMention = UnityEngine.Random.Range(0, 10) == 0; } if (showMention) { CloseWindow(SpecialThanksScreen.Instance.ShowSpecialMention); } else { CloseWindow(); } }
void SearchNearestPins(Circumference newPin, bool startOver = true) { if (startOver) { circumferencesCollided.Clear(); } // Comprobamos la distancia con el resto de bolas for (int i = 0; i < groupsDictionary.Count; i++) { if (groupsDictionary[i].isActive) { for (int c = 0; c < groupsDictionary[i].members.Count; c++) { if (IsColliding(newPin, groupsDictionary[i].members[c], marginBetweenPins)) { if (!circumferencesCollided.Contains(groupsDictionary[i].members[c])) { circumferencesCollided.Add(groupsDictionary[i].members[c]); } } } } } // Comprobamos la distancia con el rotator if (IsColliding(newPin, me)) { if (!circumferencesCollided.Contains(me)) { circumferencesCollided.Add(me); } } if (circumferencesCollided.Count == 0) { //Debug.Log ("<color=red>Error WTF (0001): No se ha encontrado ninguna colision</color>"); AnalyticsSender.SendCustomAnalitycs("wtfError", new Dictionary <string, object>() { { "type", "0001" }, { "message", "No se ha encontrado ninguna colision" } }); } }
public void AddMember(Circumference c) { if (c.tag == "Rotator") { //Debug.Log("<color=red>Error WTF 102: Rotator metido en un grupo O_o </color>"); AnalyticsSender.SendCustomAnalitycs("wtfError", new Dictionary <string, object> () { { "type", "0006" }, { "message", "Rotator metido en un grupo" } }); } if (!members.Contains(c)) { members.Add(c); c.colorGroup = index; c.name += "_group" + index; } }
public void ShowAds(bool rewarded, callback _callback = null) { resultCallback = _callback; if (Advertisement.isInitialized) { if (Advertisement.isSupported) { if (Advertisement.IsReady()) { var options = new ShowOptions { resultCallback = HandleShowResult }; string videotypeString = videoTypeStrings [rewarded ? (int)videoType.REWARDED_VIDEO : (int)videoType.SKIPPABLES_VIDEO]; AnalyticsSender.SendCustomAnalitycs("supportVideo", new Dictionary <string, object>() { { "type", rewarded ? "rewarded" : "skippable" } }); Advertisement.Show(videotypeString, options); } else { HandleShowResult(ShowResult.Failed); //Debug.Log ("Ads not Ready"); } } else { HandleShowResult(ShowResult.Failed); //Debug.Log ("Ads no soportados"); } } else { HandleShowResult(ShowResult.Failed); //Debug.Log ("Ads no iniciados"); } }
public void ProcessPin(Circumference newCircumference) { // Comprobamos si sólo hay if (circumferencesCollided.Count == 1) { if (circumferencesCollided [0].tag == "Rotator") // Si la colisión es con el rotator { groupsDictionary.Add(groupsDictionary.Count, new ColorPinsGroup(groupsDictionary.Count, newCircumference)); } else { for (int i = 0; i < groupsDictionary.Count; i++) { if (groupsDictionary [i].isActive) { if (groupsDictionary [i].Contains(circumferencesCollided [0])) { groupsDictionary [i].AddMember(newCircumference); } } } } } else if (circumferencesCollided.Count > 1) { groupsCollided.Clear(); for (int i = 0; i < circumferencesCollided.Count && !GameManager.instance.isGameOver; i++) { if (circumferencesCollided [i].tag == "Pin") { for (int j = 0; j < groupsDictionary.Count; j++) { if (groupsDictionary [j].isActive) { if (groupsDictionary [j].Contains(circumferencesCollided [i])) { if (!groupsCollided.Contains(groupsDictionary [j].index)) { groupsCollided.Add(groupsDictionary [j].index); } } } } } } if (groupsCollided.Count > 0) // ... Si hemos localizado un grupo en el que ya existe la circumferencia que evaluamos, metemos la nueva en ese grupo. { groupsDictionary[groupsCollided[0]].AddMember(newCircumference); CombineGroups(groupsCollided); } else // ... Si la circumferencia que evaluamos no pertenece a ningún grupo algo raro ha pasado y necesitamos un "salvoconducto" { string log = ""; foreach (var item in circumferencesCollided) { log += "\n - " + item.name; } //Debug.Log ("<color=red>Error WTF 0005: Los pins colisionados no están en ningún grupo. Esto no debería suceder</color> \n - Pin Evaluado: " + newCircumference.name + "\n - Pins Colisionados:" + log); AnalyticsSender.SendCustomAnalitycs("wtfError", new Dictionary <string, object>() { { "type", "0005" }, { "message", string.Format("Los pins colisionados no están en ningún grupo. \nPin Evaluado: {0} - \nPin Colisionados: {1}", newCircumference.name, log) } }); } } }
void Reposition(Circumference newPin) { //foreach (Circumference c in circumferencesCollided) // Debug.LogFormat ("<color=blue>Colision con {0} ({1}): distancia: {2}</color>", c.name, c.tag, DistanceBetweenCircumferences (newPin, c)); if (circumferencesCollided.Count > 1) { circumferencesCollided.Sort((A, B) => DistanceBetweenCircumferences(newPin, A).CompareTo(DistanceBetweenCircumferences(newPin, B))); } // Si mas de dos, nos quedamos sólo con los dos mas cercanos if (circumferencesCollided.Count > 2) { circumferencesCollided = circumferencesCollided.GetRange(0, 2); } //foreach (Circumference c in circumferencesCollided) // Debug.LogFormat ("<color=yellow>Colision aceptada: {0} ({1}) ( distancia: {2})</color>", c.name, c.tag, DistanceBetweenCircumferences (newPin, c)); switch (circumferencesCollided.Count) { case 1: /* * //debug posicion pin colisionado * DrawTheGizmo (new GizmoToDraw( GizmoType.sphere, pinsCollided[0].GetPosition(), pinsCollided[0].GetRadius(), Color.gray ) ); * //debug posicion new pin en el momento de la collision * DrawTheGizmo( new GizmoToDraw( GizmoType.sphere, newPin.GetPosition(), newPin.GetRadius(), Color.yellow ) ); */ // Reposición //newPin.transform.position = circumferencesCollided[0].GetPosition() + ( ( newPin.GetPosition() - circumferencesCollided[0].GetPosition() ).normalized * ( newPin.GetRadius() + circumferencesCollided[0].GetRadius() ) ); newPin.transform.position = circumferencesCollided[0].GetPosition() + SnapNormalizedVector(newPin.GetPosition(), circumferencesCollided[0].GetPosition()) * (newPin.GetRadius() + circumferencesCollided[0].GetRadius()); //debug posicion new pin despues de la colocación //DrawTheGizmo ( new GizmoToDraw( GizmoType.sphere, newPin.GetPosition(), newPin.GetRadius(), Color.green ) ); if (circumferencesCollided[0].tag == "Rotator") { newPin.GetComponent <Pin>().DrawSpear(); } break; case 2: Circumference A = circumferencesCollided [0]; Circumference B = circumferencesCollided [1]; if (A == B) { //Debug.Log ("Error WTF 0002: Hemos colisionador dos veces con el mismo Pin"); AnalyticsSender.SendCustomAnalitycs("wtfError", new Dictionary <string, object>() { { "type", "0002" }, { "message", "Hemos colisionador dos veces con el mismo Pin" } }); } //Solución de Fernando Rojas basada en: https://es.wikipedia.org/wiki/Teorema_del_coseno float Lc = (B.GetPosition() - A.GetPosition()).magnitude; //A.GetRadius() + B.GetRadius(); float La = B.GetRadius() + newPin.GetRadius(); float Lb = newPin.GetRadius() + A.GetRadius(); float a = Mathf.Rad2Deg * Mathf.Acos((Lb * Lb + Lc * Lc - La * La) / (2 * Lb * Lc)); Vector3 ab = (B.GetPosition() - A.GetPosition()).normalized; Quaternion rot = Quaternion.AngleAxis(a, Vector3.forward); Vector3 Solution1 = A.GetPosition() + rot * ab * Lb; rot = Quaternion.AngleAxis(a, -Vector3.forward); Vector3 Solution2 = A.GetPosition() + rot * ab * Lb; #region "Otra solución - Solo funciona con circulos con igual radio" /* * //Solución para el ajuste de posición. http://stackoverflow.com/questions/18558487/tangent-circles-for-two-other-circles * // 1 Calculate distance from A to B -> |AB|: * float AB = Vector3.Distance(A.GetPosition(), B.GetPosition()); * // 2 Checks whether a solution exist, it exist only if: * Debug.Assert(AB <= 4 * newPin.GetComponent<Circumference>().GetRadius()); * // 3 If it exist, calculate half-point between points A and B: * Vector2 H = new Vector2( A.GetPosition().x + ( (B.GetPosition().x - A.GetPosition().x) / 2 ), A.GetPosition().y + ( (B.GetPosition().y - A.GetPosition().y) / 2 ) ); * // 4 Create normalized perpendicular vector to line segment AB: * Vector2 HC_perp_norm = new Vector2( (B.GetPosition().y - A.GetPosition().y) / AB, -(B.GetPosition().x - A.GetPosition().x) / AB ); * // 5 Calculate distance from this H point to C point -> |HC|: * float HCpos = Mathf.Abs( 0.5f * Mathf.Sqrt( 16 * ( newPin.GetRadius() * newPin.GetRadius() ) - (AB*AB) ) ); * float HCneg = -( 0.5f * Mathf.Sqrt( 16 * ( newPin.GetRadius() * newPin.GetRadius() ) - (AB*AB) ) ); * // Posibles soluciones * Vector3 Solution1 = new Vector3 (H.x + (HCpos * HC_perp_norm.x), H.y + (HCpos * HC_perp_norm.y), 0); * Vector3 Solution2 = new Vector3 (H.x + (HCneg * HC_perp_norm.x), H.y + (HCneg * HC_perp_norm.y), 0); */ #endregion // nos quedamos con la mas cercana al spawner Vector3 sol = DistanceBetweenPoints(Solution1, GameManager.instance.spawner.transform.position) < DistanceBetweenPoints(Solution2, GameManager.instance.spawner.transform.position) ? Solution1 : Solution2; if (float.IsNaN(sol.x)) { //Debug.Log ("<color=red>Error WTF 0003: Naaaaaaan</color>"); AnalyticsSender.SendCustomAnalitycs("wtfError", new Dictionary <string, object>() { { "type", "0003" }, { "message", "La reposición contiene numero inválidos: (" + sol.ToString() + "). Cambio NaN -> cero" } }); sol = new Vector3(float.IsNaN(sol.x) ? 0 : sol.x, float.IsNaN(sol.y) ? 0 : sol.y, float.IsNaN(sol.y) ? 0 : sol.y); // TODO: Enviar como estadística de errores } else { // Posición final newPin.transform.position = sol; } /* * /// DEBUG /// * //debug posicion new pin en el momento de la collision * DrawTheGizmo ( new GizmoToDraw( GizmoType.sphere, newCircumference.GetPosition(), newCircumference.GetRadius(), Color.white ) ); * //debug posicion pins colisionados * //A * DrawTheGizmo ( new GizmoToDraw( GizmoType.sphere, A.GetPosition(), A.GetRadius(), Color.green ) ); * DrawTheGizmo ( new GizmoToDraw( GizmoType.line, A.GetPosition(), A.GetPosition() + (B.GetPosition () - A.GetPosition()).normalized * A.GetRadius(), Color.green ) ); // Ra to Rb * DrawTheGizmo ( new GizmoToDraw( GizmoType.line, A.GetPosition(), A.GetPosition() + (Solution1 - A.GetPosition()).normalized * A.GetRadius(), Color.green ) );// Linea A-Solution1 * DrawTheGizmo ( new GizmoToDraw( GizmoType.line, A.GetPosition(), A.GetPosition() + (Solution2 - A.GetPosition()).normalized * A.GetRadius(), Color.green ) );//Linea B-Solution2 * //B * DrawTheGizmo ( new GizmoToDraw( GizmoType.sphere, B.GetPosition(), B.GetRadius(), Color.green ) ); * DrawTheGizmo ( new GizmoToDraw( GizmoType.line, B.GetPosition(), B.GetPosition() + (A.GetPosition () - B.GetPosition()).normalized * B.GetRadius(), Color.green ) ); // Rb to Ra * DrawTheGizmo ( new GizmoToDraw( GizmoType.line, B.GetPosition(), B.GetPosition() + (Solution1 - B.GetPosition()).normalized * B.GetRadius(), Color.green ) ); // Linea A-Solution1 * DrawTheGizmo ( new GizmoToDraw( GizmoType.line, B.GetPosition(), B.GetPosition() + (Solution2 - B.GetPosition()).normalized * B.GetRadius(), Color.green ) ); // Linea B-Solution2 * //Solution 1 * DrawTheGizmo ( new GizmoToDraw( GizmoType.sphere, Solution1, newCircumference.GetRadius(), Color.yellow ) ); * DrawTheGizmo ( new GizmoToDraw( GizmoType.line, Solution1, Solution1 + (A.GetPosition () - Solution1).normalized * newCircumference.GetRadius(), Color.yellow ) ); // Linea Solution1-A * DrawTheGizmo ( new GizmoToDraw( GizmoType.line, Solution1, Solution1 + (B.GetPosition () - Solution1).normalized * newCircumference.GetRadius(), Color.yellow ) ); // Linea Solution1-B * //Solution 2 * DrawTheGizmo ( new GizmoToDraw( GizmoType.sphere, Solution2, newCircumference.GetRadius(), Color.yellow ) ); * DrawTheGizmo ( new GizmoToDraw( GizmoType.line, Solution2, Solution2 + (A.GetPosition () - Solution2).normalized * newCircumference.GetRadius(), Color.yellow ) ); // Linea Solution2-A * DrawTheGizmo ( new GizmoToDraw( GizmoType.line, Solution2, Solution2 + (B.GetPosition () - Solution2).normalized * newCircumference.GetRadius(), Color.yellow ) ); // Linea Solution2-B * //Posicion fianl decidida... * //DrawTheGizmo ( new GizmoToDraw( GizmoType.sphere, newPin.transform.position, newCircumference.GetRadius(), Color.black ) ); */ break; default: //Debug.Log(string.Format("<color=red> ERROR WTF 0004: número de colisiones incorrectas: {0}</color>", circumferencesCollided.Count.ToString())); AnalyticsSender.SendCustomAnalitycs("wtfError", new Dictionary <string, object>() { { "type", "0004" }, { "message", "número de colisiones incorrectas: (" + circumferencesCollided.Count.ToString() + ")" } }); break; } }