public void OnPointerExit(PointerEventData data) { if (countdownActionCount == 0 && icon) { Destroy(icon); BulletsController.GetInstance().RemoveBonusAction(bullet); } }
public void OnPointerEnter(PointerEventData data) { if (countdownActionCount > 0 && BulletsController.GetInstance().GetBonusAtIndex(0) == bullet) { countdownActionCount--; bullet.countdownText.text = countdownActionCount.ToString() + " в"; } }
void SpawnBonuse() { float xTo = TurretsController.GetInstance().rightTurret.gameObject.transform.position.x; float yTo = TurretsController.GetInstance().topTurret.gameObject.transform.position.y; Vector2 spawnPoint = WaveSpawner.SelectRandomRectangleSpawnPoint(-xTo, xTo, -yTo, yTo); GameObject spriteObject = Instantiate(bullet.sprite, spawnPoint, Quaternion.identity, BulletsController.GetInstance().bonusesPool); Sprite sprite = spriteObject.GetComponent <Sprite>(); sprite.activateFunc = delegate { Activate(); }; }
public void Activate() { if (!icon) { BulletsController.GetInstance().AddNewBonusAction(bullet); icon = Instantiate(bullet.icon, BulletsController.GetInstance().bonusesPanelUI); } icon.transform.SetAsFirstSibling(); countdownActionTime = actionTime - 1; bullet.countdownText = icon.GetComponentInChildren <Text>(); }
void Update() { if (countdownActionTime > 0) { countdownActionTime -= Time.deltaTime; bullet.countdownText.text = (Mathf.Round(countdownActionTime) + 1).ToString() + " с"; if (countdownActionTime <= 0f) { Destroy(icon); BulletsController.GetInstance().RemoveBonusAction(bullet); } } }
void Awake() { rb = GetComponent <Rigidbody2D>(); bullet = new Bullet(BulletsController.GetInstance().currentBullet); }