public void Strike() //выстрел шариком { if (!IsStriked) { ball.transform.position = spawn.position; spawn.gameObject.SetActive(false); ball.SetActive(true); IsStriked = true; ballPhysics.SetVelocity(_ballSpeed, ballDestination); } }
IEnumerator Ball() //бонусный шар { Debug.Log(_bonusTime); GameObject b; b = GameObject.FindGameObjectWithTag("Player"); newBall = Instantiate(b, b.transform.position, new Quaternion()); BallPhysics bf = newBall.GetComponent <BallPhysics>(); bf.SetVelocity(b.GetComponent <BallPhysics>().GetVelocity().magnitude, new Vector2(Random.Range(0f, 1f), Random.Range(0f, 1f))); bf.HitEvent += Camera.main.GetComponent <GameManager>().HitBrick; bf.HitEvent += BallDeathField; yield return(new WaitForSeconds(_bonusTime)); Destroy(newBall); Destroy(gameObject); }
void Start() { switch (bonus) //установка цвета спрайта бонуса, в зависимости от типа { case Bonus.SpeedPlus: spriteRenderer.color = Color.yellow; break; case Bonus.SpeedMinus: spriteRenderer.color = Color.black; break; case Bonus.Ball: spriteRenderer.color = Color.green; break; case Bonus.Platform: spriteRenderer.color = Color.red; break; } bonusPhysics.HitEvent += BonusApply; bonusPhysics.HitEvent += DeathField; bonusPhysics.SetVelocity(9.8f, new Vector2(0, -1)); }