Esempio n. 1
0
 /// <summary>
 /// Shoots a projectile by getting it from a designated projectile pool.
 /// Also changes the color of the shooting button indicating that the button
 /// was pressed.
 /// </summary>
 public void Shoot()
 {
     knob.GetComponent <Image>().color = new Color(255, 138, 0, 233);
     if (lastTimeShot > reloadTime)
     {
         pooler.ActivateProjectile();
         lastTimeShot = 0;
     }
 }
    protected override void DoFixedUpdate()
    {
        Vector3 pos = transform.position;

        body.MovePosition(new Vector2(pos.x, pos.y) + direction * speed * Time.deltaTime);
        lastTimeShot              = lastTimeShot > 1 ? 0 : lastTimeShot + Time.fixedDeltaTime;
        lastTimeDirectionChanged += Time.fixedDeltaTime;
        if (Random.Range(0, 100) <= shootProbabilty && lastTimeShot > 1)
        {
            pooler.ActivateProjectile(transform);
        }
    }