public IEnumerator ReloadLoadSceneSmoth() { _resetingPosition = true; _roy = null; _klunk = null; bool ok = false; LeanTween.value(gameObject, (x) => { _hidder.alpha = x; }, 0, 1, _fadeInTime) .setEase(_fadeInType) .setOnComplete(() => { ok = true; }); yield return(new WaitUntil(() => { return ok; })); yield return(SceneManager.LoadSceneAsync(SceneManager.GetActiveScene().buildIndex)); LeanTween.value(gameObject, (x) => { _hidder.alpha = x; }, 1, 0, _fadeOutTime) .setEase(_fadeOutType); _resetingPosition = false; SceneFlow currentSceneFlow = FindObjectOfType <SceneFlow>(); if (currentSceneFlow == null) { Destroy(gameObject); yield break; } _bounds = currentSceneFlow._bounds; _finishZone = currentSceneFlow._finishZone; _roy = FindObjectOfType <Roy>(); _klunk = FindObjectOfType <Klunk>(); Destroy(currentSceneFlow.gameObject); }
public void Draw(SpriteBatch spriteBatch, int screenWidth, int screenHeight) { spriteBatch.Draw(Background, new Rectangle(0, 0, screenWidth, screenHeight), Color.White); int d = (int)Roy.Position.X + Roy.Bounds.Width / 2 - screenWidth / 2; d = MathHelper.Clamp(d, 0, LevelWidth - screenWidth); Rectangle screenWorldRect = new Rectangle(d, 0, screenWidth, screenHeight); foreach (Tile tile in Tiles) { if (tile.Bounds.Intersects(screenWorldRect)) { tile.Draw(spriteBatch, d); } } foreach (Entity entity in Entities) { if (entity.Bounds.Intersects(screenWorldRect)) { entity.Draw(spriteBatch, d); } } Roy.Draw(spriteBatch, d); }
public void Update(GameTime gameTime) { Roy.Update(gameTime); foreach (Entity entity in Entities) { entity.Update(gameTime); } }
private void Awake() { _roy = FindObjectOfType <Roy>(); _klunk = FindObjectOfType <Klunk>(); _roy.OnCurrentEnergyChange += _roy_OnCurrentEnergyChange; _roy.OnCurrentFuelChange += _roy_OnCurrentFuelChange; _klunk.OnCurrentEnergyChange += _klunk_OnCurrentEnergyChange; _klunk.OnCurrentFuelChange += _klunk_OnCurrentFuelChange; }
private void OnTriggerEnter(Collider other) { Roy possivleRoy = other.GetComponent <Roy>(); if (!possivleRoy) { return; } possivleRoy.AddBattery(); Destroy(gameObject); }
private void Awake() { savePath = Path.Combine(Application.persistentDataPath, "saveFile"); royStats = GameObject.Find("Set_PlayerRoy").GetComponent <Roy>(); klunkStats = GameObject.Find("Set_KLUNK").GetComponent <Klunk>(); if (File.Exists(savePath)) { Vector2[] stats = LoadStats(); royStats.SetCurrentHpSp(stats[0]); klunkStats.SetCurrentHpSp(stats[1]); } }
public void Pick(float perSecond) { OnPump?.Invoke(); Roy roy = GetComponent <Roy>(); if (roy) { roy.DecreaseFuel(perSecond); return; } Klunk klunk = GetComponent <Klunk>(); if (klunk) { klunk.DecreaseFuel(perSecond); } }
private void Awake() { DontDestroyOnLoad(gameObject); _roy = FindObjectOfType <Roy>(); _klunk = FindObjectOfType <Klunk>(); }