Exemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        // only go one if Orthello is initialized
        if (!OT.isValid)
        {
            return;
        }

        // We call the application initialization function from Update() once
        // because we want to be sure that all Orthello objects have been started.
        if (!initialized)
        {
            Initialize();
            return;
        }
        // Rotate the gun animation sprite towards the mouse on screen
        gun.RotateTowards(OT.view.mouseWorldPosition);
        // Rotate our bullet prototype as well so we will instantiate a
        // 'already rotated' bullet when we shoot


        // check if the left mouse button was clicked
        if (Input.GetMouseButtonDown(0))
        {
            // Create a new bullet
            OTSprite nBullet = OT.CreateSprite("bullet");
            // Set bullet's position at approximately the gun's shooting barrel
            nBullet.position = gun.position + (gun.yVector * (gun.size.y / 2));
            nBullet.rotation = gun.rotation;
            // Play the gun's shooting animation frameset once
            gun.PlayOnce("shoot");
        }

        //If we have less than 15 objects within Orthello we will create a random asteroid
        if (OT.objectCount <= 15)
        {
            RandomBlock(OT.view.worldRect, 0.6f, 1.2f, null);
        }
    }