public void SaveGameData() { DatabaseReference reference = FirebaseDatabase.DefaultInstance.GetReference("GalaticRangers"); DatabaseReference gameReference = reference.Child("Games").Push(); GameLogger gameLogger = GameLogger.GetInstance(); string JSONGameLogger = JsonUtility.ToJson(gameLogger); Debug.Log("Json: " + JSONGameLogger); gameReference.SetRawJsonValueAsync(JSONGameLogger).ContinueWithOnMainThread(task => { if (task.Exception != null) { Debug.Log("failed: Couldn't save the data to the database."); } else if (task.IsCompleted) { Debug.Log("saving completed."); } }); //HighscoreModel model = new HighscoreModel("Ultimate_Gamer", 9999, gameReference.Key); //HighscoreService.GetInstance().SaveOverAllHighscore(model); Debug.Log("Logging Stopped"); isLoggingStarted = false; gameLogger.Reset(); }
public void OnDestroy() { if (lifeTimer > 0f) { GameLogger.GetInstance().PlayerHitShot(); } }
// Update is called once per frame void Update() { int currentScore = GameLogger.GetInstance().GetScore(); text.text = "Score: " + currentScore; finalScoreText.text = currentScore.ToString(); LerpChangeLightSettings(0, 0, 0.025f); }
private void SpawnLaser(GameObject _laserPrefab) { GameLogger.GetInstance().PlayerFiredShot(); RestartChargedTimer(); GameObject laser = Instantiate(_laserPrefab, transform.position, transform.localRotation); laser.GetComponent <LockOn>().target = target; }
void OnTriggerEnter(Collider collider) { if (collider.tag == "Enemy") { GameObject collided = collider.gameObject; BehaviourStrategy enemy = collided.GetComponent <BehaviourStrategy>(); ChangeLightSettings(5.03f, 10.46f); TakeDamage((int)enemy.getDamage()); collider.gameObject.SetActive(false); Instantiate(explosionObject, collider.gameObject.transform.position, Quaternion.identity); GameLogger.GetInstance().PlayerGotHit(new PlayerHitInfo(0, collided.name, enemy.getDamage())); } }
void Start() { ISerializer saver = new BaseSerializer(); IShopController shop = new ShopCont_r(); IPlayer player = new GamePlayer(); IShip ship = new VikingShip(); Assets.Scripts.ILogger log = GameLogger.GetInstance(); saver.Serialize(shop); string playr = saver.Serialize(player); string shp = saver.Serialize(ship); saver.Deserialize(shp); }
private void OnTriggerEnter(Collider collider) { if (collider.tag == "Laser") { Destroy(collider.gameObject); laserBehavior laser = collider.gameObject.GetComponent <laserBehavior>(); health -= laser.GetDamage(); } if (health <= 0) { gameObject.GetComponent <Renderer>().material = flashMat; explode(); Invoke("setInActive", 0.05f); GameLogger.GetInstance().PlayerKilledEnemy(); } if (collider.tag == "ObjectDestroyer") { Invoke("setInActive", 0.05f); } }