/// <summary> Handles when a pin is clicked </summary> public void Pin_Click(OnlineMapsMarkerBase marker) { try { Vector2 pos = OnlineMapsLocationService.instance.position; Vector2 markerPos = marker.position; double pinDist = PinUtilities.DistanceInMeters(pos.y, pos.x, markerPos.y, markerPos.x); if (pinDist < pinRadius) { PointData pd = PinUtilities.GetPointData(marker.tags, PinUtilities.PointDatas); if (PinUtilities.GetTypeFromTag(marker.tags) != "Tokens") { UserUtilities.AllocatePoints(pd._Value); UIManager.Instance.IndicateScore(pd._Value, true); SoundManager.Instance.PlaySound("CoinCollect"); long now = (long)(DateTime.UtcNow - epochStart).TotalMilliseconds; PinUtilities.pinDeltas[marker.label] = now; pd.RemovePin(); PinUtilities.SavePins(); UserUtilities.Save(); Organizations pinOrg = (Organizations)Enum.Parse(typeof(Organizations), pd._Type.ToString()); if (MinigamePinUnlock.Contains(pinOrg) && MiniGameEnabledOrgs.Contains(pinOrg)) { Unlock(pinOrg); } if (TriviaEnabledOrgs.Contains(pinOrg)) { TriviaGame.CheckForTrivia(marker.label); } return; } else { pd = PinUtilities.GetPointData(marker.tags, PinUtilities.TokenPointDatas); TokenPinActivate(pd, pd._Position.Latitude.ToString() + pd._Position.Longitude.ToString()); } } } catch (Exception e) { Debug.Log("ERROR: " + e.Message); } }
public override void EnterState(State state) { switch (state) { case State.Splash: UI.Splash_PNL.SetActive(true); splashTimer = 0; SoundManager.Instance.PlayMusic("HRCA_MainLoop", Music); break; case State.Menu: BackGroundImage.enabled = true; UI.Menu_PNL.SetActive(true); SetHighScore(GameManager.MGD.Highscore.ToString()); Init(); break; case State.Pregame: BackGroundImage.enabled = false; UI.Playing_PNL.SetActive(true); break; case State.Playing: BackGroundImage.enabled = false; UI.Playing_PNL.SetActive(true); if (Last_State != State.Paused) { levelManager.SpawnBird(); } break; case State.Paused: UI.Paused_PNL.SetActive(true); Time.timeScale = 0; break; case State.Gameover: SoundManager.Instance.PlaySound("HRCA_game_over", SFX); GameManager.Instance.analytics.LogTiming(new TimingHitBuilder().SetTimingCategory(Name).SetTimingInterval((long)gameDuration).SetTimingName("Playtime")); GameManager.Instance.analytics.LogEvent(new EventHitBuilder().SetEventCategory(Name).SetEventAction("Points").SetEventValue(Score)); GameManager.Instance.analytics.LogEvent(new EventHitBuilder().SetEventCategory(Name).SetEventAction("Tokens").SetEventValue((long)(Score * tokenRatio))); UI.Gameover_PNL.SetActive(true); BackGroundImage.enabled = true; UI.GameOverScore_Text.text = Score.ToString(); UI.GameOverToken_Text.text = (Score * tokenRatio).ToString(); if (Score > 0) { UpdateHighScore(Score); UserUtilities.AllocatePoints((int)(Score * tokenRatio)); } break; } }
public override void EnterState(State state) { switch (state) { case State.Splash: //UI.Splash_PNL.SetActive(true); break; case State.Menu: //UI.Menu_PNL.SetActive(true); break; case State.Playing: UI.Playing_PNL.SetActive(true); break; case State.Paused: UI.Paused_PNL.SetActive(true); break; case State.Gameover: //UI.Gameover_PNL.SetActive(true); Curtain.SetActive(true); if (fails == 0 && !TimesUp) { ResultImg.sprite = correctImg; SoundManager.Instance.PlaySound("Quiz_Right", SFX); UserUtilities.AllocatePoints(CurrentQuwestion.Value); UIManager.Instance.IndicateScore(CurrentQuwestion.Value, true); UserUtilities.Save(); } else if (TimesUp) { ResultImg.sprite = TimesUpImg; SoundManager.Instance.PlaySound("Quiz_GameOver", SFX); } else { ResultImg.sprite = incorrectImg; SoundManager.Instance.PlaySound("Quiz_Wrong", SFX); } break; } }
/// <summary> Handles the entrance of a state dependant of state given </summary> public override void EnterState(State state) { switch (state) { case State.Splash: UI.Splash_PNL.SetActive(true); splashTimer = 0; SoundManager.Instance.PlayMusic("MPL_MainLoop", Music); break; case State.Menu: UI.Menu_PNL.SetActive(true); SetHighScore(GameManager.MGD.Highscore.ToString()); break; case State.Pregame: UI.Playing_PNL.SetActive(true); BoardSetup = true; CreatCells(); AddTiles("random"); matchCountGoal = (TileCountScale * TileCountScale * TileCountScale); break; case State.Playing: UI.Playing_PNL.SetActive(true); break; case State.Paused: UI.Paused_PNL.SetActive(true); break; case State.Gameover: GameManager.Instance.analytics.LogTiming(new TimingHitBuilder().SetTimingCategory(Name).SetTimingInterval((long)gameDuration).SetTimingName("Playtime")); GameManager.Instance.analytics.LogEvent(new EventHitBuilder().SetEventCategory(Name).SetEventAction("Points").SetEventValue(Score)); GameManager.Instance.analytics.LogEvent(new EventHitBuilder().SetEventCategory(Name).SetEventAction("Tokens").SetEventValue((long)(Score * tokenRatio))); UI.Gameover_PNL.SetActive(true); KillAllTiles(); UI.GameOverScore_Text.text = Score.ToString(); UI.GameOverToken_Text.text = (Score * tokenRatio).ToString(); UpdateHighScore(Score); UserUtilities.AllocatePoints((int)(Score * tokenRatio)); SoundManager.Instance.PlaySound("CoinCollect"); break; } }
// QR found by cam handler private void HandleOnQRCodeFound(ZXing.BarcodeFormat barCodeType, string barCodeValue) { QRCodeManager.Instance.StopScanning(); Product prod = Product.Parse(barCodeValue); if (prod == null) { QRCode qr = QRCode.QRParse(barCodeValue); if (ValidQR(qr.RawData)) { UserUtilities.AllocatePoints(qr.TokenValue); IndicateScore(qr.TokenValue, true); SoundManager.Instance.PlaySound("CoinCollect"); GameManager.Instance.analytics.LogEvent(new EventHitBuilder().SetEventCategory("Token Distribution").SetEventAction(qr.QRType.ToString()).SetEventValue(qr.TokenValue)); if (qr.QRType != QRCode.QRTypes.Tokens) { GameManager.Organizations Org = (GameManager.Organizations)Enum.Parse(typeof(GameManager.Organizations), qr.QRType.ToString()); if (GameManager.Instance.MiniGameEnabledOrgs.Contains(Org)) { GameManager.Instance.Unlock(Org); } } } else { DisplayNotification(true, "You have already redeemed this reward today."); } } else { GameObject Popup = Instantiate(Confirmtion_Prefab, gameObject.transform); ConfirmationPopup conf = Popup.GetComponent <ConfirmationPopup>(); conf.prod = prod; conf.Message.text = "Are you certain you would like to spend " + prod.TokenValue + " Tokens to recieve " + prod.ProductName + "."; } List_BTN.interactable = false; List_Tab.SetActive(true); Scan_BTN.interactable = true; Scan_Tab.SetActive(false); }
// Event executes when token pins are clicked private void TokenPinActivate(PointData pinData, string key) { if (pinData._Jackpot) { UserUtilities.AllocatePoints(pinData._Value * jackpotMultiplier); UIManager.Instance.IndicateScore(pinData._Value * jackpotMultiplier, true); } else { UserUtilities.AllocatePoints(pinData._Value); UIManager.Instance.IndicateScore(pinData._Value, true); } SoundManager.Instance.PlaySound("CoinCollect"); long now = (long)(DateTime.UtcNow - epochStart).TotalMilliseconds; PinUtilities.tokenPinDeltas[key] = now; pinData.RemovePin(); PinUtilities.SaveTokenPins(); UserUtilities.Save(); }