//private AudioSource footsteps; // Use this for initialization void Start() { controller = GetComponent <CharacterController>(); //footsteps = GetComponent<AudioSource> (); tile_mngr_scrpt = tileScript.GetComponent <TileMangerScript> (); dest_obj_scrpt = this.GetComponent <DestroyObjects> (); }
// Use this for initialization void Start() { dest_obj_scrpt = player.GetComponent <DestroyObjects> (); spawnZ += 2 * TileLength; playerTransform = GameObject.FindGameObjectWithTag("Player").transform; for (int i = 0; i < tilesOnScreen; i++) { spawnTile(); } }
public void Remove(QBehavior script) { Objects.Remove(script.Parent); if (script is IQLoad l) { LoadObjects.Remove(l); } if (script is IQStart s) { StartObjects.Remove(s); } if (script is IQFixedUpdate u) { FixedUpdateObjects.Remove(u); } if (script is IQUpdate up) { UpdateObjects.Remove(up); } if (script is IQLateUpdate late) { LateUpdateObjects.Remove(late); } if (script is IQSprite ds) { SpriteObjects.Remove(ds); } if (script is IQGui dg) { GuiObjects.Remove(dg); } if (script is IQDestroy des) { des.OnDestroy(); DestroyObjects.Remove(des); } if (script is IQUnload un) { UnloadObjects.Remove(un); } //invokes event even if does not inherit OnDestroy script.DestroyEvent(); }
public void Add(QBehavior script) { Objects.Add(script.Parent); if (script is IQLoad l) { LoadObjects.Add(l); } if (script is IQStart s) { StartObjects.Add(s); } if (script is IQFixedUpdate u) { FixedUpdateObjects.Add(u); } if (script is IQUpdate up) { UpdateObjects.Add(up); } if (script is IQLateUpdate late) { LateUpdateObjects.Add(late); } if (script is IQSprite ds) { SpriteObjects.Add(ds); } if (script is IQGui dg) { GuiObjects.Add(dg); } if (script is IQDestroy des) { DestroyObjects.Add(des); } if (script is IQUnload un) { UnloadObjects.Add(un); } }
// Update is called once per frame void Update() { GameObject interaction = GameObject.Find("Interaction"); GameObject arCamera = GameObject.Find("AR Camera"); Place place = interaction.GetComponent <Place>(); DestroyObjects destroy = arCamera.GetComponent <DestroyObjects>(); skySpawnCount = place.skySpawnCount; score = destroy.enemyKillCount; if (skySpawnCount > 0) { currentTime -= 1 * Time.deltaTime; int finalTime = (int)currentTime; countDown.GetComponent <UnityEngine.UI.Text>().text = finalTime.ToString(); } if (currentTime <= 0) { currentTime = 0; if (score >= levelPassScore) { winScreen.SetActive(true); if (PlayerPrefs.GetInt("levelReach") < levelToUnlock) { PlayerPrefs.SetInt("levelReach", levelToUnlock); } Debug.Log("CountDown win levelName :" + levelName); Debug.Log(levelName); Debug.Log("CountDown win loggedUser " + loggedUser.UserId); Debug.Log(loggedUser.UserId); playerReadRef = FirebaseDatabase.DefaultInstance.GetReference("players"); // Debug.Log(string.Format("playerReadRef {0}...", playerReadRef)); //playerReadRef.Child(loggedUser.UserId).Child("test").SetValueAsync(4); if (levelName.Trim().Equals("Level01")) { logUserCurrentAchiveLevel = 2; Debug.Log("playerReadRef level01 value save{0}..."); playerReadRef.Child(loggedUser.UserId).Child("score").Child("level1").SetValueAsync(score); playerReadRef.Child(loggedUser.UserId).Child("totalscore").SetValueAsync(score); playerReadRef.Child(loggedUser.UserId).Child("score").Child("level2").GetValueAsync().ContinueWith(task => { if (task.IsFaulted) { // Handle the error... Debug.Log(" start level Handle the error task.IsFaulted"); } else if (task.IsCompleted) { Debug.Log("Task Completed start level :"); DataSnapshot snapshot = task.Result; Debug.Log("save total score level 2" + snapshot.Value); int dbscore = int.Parse(snapshot.Value.ToString()); Debug.Log(" save total dbscore" + dbscore); int total = dbscore + score; playerReadRef.Child(loggedUser.UserId).Child("totalscore").SetValueAsync(total); } else { Debug.Log("Else condtion"); } }); } else if (levelName.Trim().Equals("Level02")) { Debug.Log("playerReadRef level02 value save{0}..."); logUserCurrentAchiveLevel = 3; playerReadRef.Child(loggedUser.UserId).Child("achievedlevel").SetValueAsync(3); playerReadRef.Child(loggedUser.UserId).Child("score").Child("level2").SetValueAsync(score); playerReadRef.Child(loggedUser.UserId).Child("score").Child("level1").GetValueAsync().ContinueWith(task => { if (task.IsFaulted) { // Handle the error... Debug.Log(" start level Handle the error task.IsFaulted"); } else if (task.IsCompleted) { Debug.Log("Task Completed start level :"); DataSnapshot snapshot = task.Result; Debug.Log("save total score level 1" + snapshot.Value); int dbscore = int.Parse(snapshot.Value.ToString()); Debug.Log(" save total dbscore" + dbscore); int total = dbscore + score; playerReadRef.Child(loggedUser.UserId).Child("totalscore").SetValueAsync(total); } else { Debug.Log("Else condtion"); } }); } else { Debug.Log("unexpeteted level"); } } if (score < levelPassScore) { Debug.Log("CountDown lost levelName :" + levelName); Debug.Log(levelName); Debug.Log("CountDown lost loggedUser " + loggedUser.UserId); Debug.Log(loggedUser.UserId); playerReadRef = FirebaseDatabase.DefaultInstance.GetReference("players"); //Debug.Log(string.Format("playerReadRef {0}...", playerReadRef)); playerReadRef.Child(loggedUser.UserId).Child("test").SetValueAsync(3); if (levelName.Trim().Equals("Level01")) { Debug.Log("playerReadRef level01 lost value save..."); playerReadRef.Child(loggedUser.UserId).Child("score").Child("level1").SetValueAsync(score); playerReadRef.Child(loggedUser.UserId).Child("totalscore").SetValueAsync(score); playerReadRef.Child(loggedUser.UserId).Child("score").Child("level2").GetValueAsync().ContinueWith(task => { if (task.IsFaulted) { // Handle the error... Debug.Log(" start level Handle the error task.IsFaulted"); } else if (task.IsCompleted) { Debug.Log("Task Completed start level :"); DataSnapshot snapshot = task.Result; Debug.Log("save total score level 2" + snapshot.Value); int dbscore = int.Parse(snapshot.Value.ToString()); Debug.Log("save total dbscore " + dbscore); int total = dbscore + score; playerReadRef.Child(loggedUser.UserId).Child("totalscore").SetValueAsync(total); } else { Debug.Log("Else condtion"); } }); } else if (levelName.Trim().Equals("Level02")) { Debug.Log("playerReadRef level02 lost value save{0}..."); playerReadRef.Child(loggedUser.UserId).Child("score").Child("level2").SetValueAsync(score); playerReadRef.Child(loggedUser.UserId).Child("score").Child("level1").GetValueAsync().ContinueWith(task => { if (task.IsFaulted) { // Handle the error... Debug.Log(" start level Handle the error task.IsFaulted"); } else if (task.IsCompleted) { Debug.Log("Task Completed start level :"); DataSnapshot snapshot = task.Result; Debug.Log("save total score level 1" + snapshot.Value); int dbscore = int.Parse(snapshot.Value.ToString()); Debug.Log(" save total dbscore" + dbscore); int total = dbscore + score; playerReadRef.Child(loggedUser.UserId).Child("totalscore").SetValueAsync(total); } else { Debug.Log("Else condtion"); } }); } else { Debug.Log("unexpeteted level"); } lostScreen.SetActive(true); } } }