public void ShootCannon()
    {
        GameObject thisCannonBall = Instantiate(cannonBall, transform.position, transform.rotation);

        thisCannonBall.GetComponent <Rigidbody>().AddRelativeForce(firePower, 0, 0, ForceMode.Impulse);
        thisCannonBall.GetComponent <CannonBall>().SetMountainTops(MountainGenerator.GetMountainTops());
        thisCannonBall.GetComponent <CannonBall>().SetMountainTop(MountainGenerator.GetMountainTop());
    }
Exemple #2
0
    // Update is called once per frame
    void Update()
    {
        if (_turkey.minX > 8.04)
        {
            Destroy(gameObject);
            TurkeyFactory.DecrementTurkeyAmount();
        }

        jumpTimer += Time.deltaTime;
        if (_turkey.grounded && jumpTimer > jumpPeriod)
        {
            jumpTimer = 0.0f;
            System.Random rnd = new System.Random();
            if (rnd.NextDouble() < 0.6)
            {
                _turkey.TurkeyJump();
            }
        }

        if (Input.GetKeyDown(KeyCode.S))
        {
            _turkey.SlightJump();
        }

        float wf = 0;

        if (_turkey.maxX > -8.77)
        {
            wf = -0.008f;
        }

        if (_turkey.minY > MountainGenerator.GetMountainTop())
        {
            _turkey.UpdateTurkey(Wind.currentWind * 0.02f, wf);
        }
        else
        {
            _turkey.UpdateTurkey(0, wf);
        }

        RenderPoints();
        RenderLines();
        time += Time.deltaTime;

        CannonBallCollisionDetection();
        if (time >= interpolationPeriod)
        {
            time = 0.0f;
            if (_turkey.grounded && _turkey.maxX < -8.77)
            {
                TurkeyLateralMove();
            }
        }
        MountainCollisionDetection();
    }