Example #1
0
    void Start()
    {
        mControl = parent.GetComponent <MovementControl>();
        rBody    = GetComponent <Rigidbody2D>();

        if (parent.tag == "Enemy")
        {
            gameObject.layer = 12;
        }

        if (rBody != null && mControl != null)
        {
            rBody.AddForce(new Vector2(speedX * mControl.GetFacingDir(), speedY), ForceMode2D.Impulse);
        }

        AudioControl.PlayerShootFireball(); //Toistaa äänen
    }
Example #2
0
    private void CheckShooting()
    {
        if (mControl.currentPower != null)
        {
            if (Vector2.Distance(player.transform.position, transform.position) < shootingDistance)
            {
                int facingDirToPlayer = (int)player.transform.position.x - (int)transform.position.x;
                if (facingDirToPlayer < 0)
                {
                    facingDirToPlayer = -1;
                }
                else
                {
                    facingDirToPlayer = 1;
                }

                if (mControl.GetFacingDir() == facingDirToPlayer)
                {
                    mControl.Shoot();
                }
            }
        }
    }