public void destroyBlock() { float time = Random.Range(0.6f, 0.8f); float delay = Random.Range(0.05f, 0.15f); GameObject guiObject = BezierHelper.moveTo(gameObject, uiTarget, fakeBlock, time, delay); guiObject.GetComponent <FakeBlockController>().Invoke("OnFinishAnimation", time + delay); guiObject.GetComponent <UISprite>().spriteName = GetComponentInChildren <SpriteRenderer>().sprite.name;; guiObject.GetComponent <UISprite>().MarkAsChanged(); uiTarget.GetComponent <ResourceManager>().Invoke("addBlock", time + delay); Destroy(this.gameObject); //TODO finish sound // TODO allow for the particles To fade }
void giveReward() { Game.Instance.playerStuffManager.money += client.reward; int coinsToSpawn = (client.reward / 5); GameObject uiTarget = Game.Instance.playerStuffManager.moneyIcon; for (int i = 0; i < coinsToSpawn; ++i) { // vizualize float time = Random.Range(0.6f, 0.8f); float delay = (0.02f * i); GameObject guiObject = BezierHelper.moveTo(avatar.gameObject, uiTarget, floatingCoinPrefab, time, delay); Destroy(guiObject, time + delay); // play sound only once if (i == 0) { uiTarget.GetComponent <PlayerCoinsController>().Invoke("OnFinishAnimation", time + delay); } } }