Beispiel #1
0
    void shootMortarBoy()
    {
        gameObject.transform.LookAt(mortarBoy.transform.position);
        gameObject.transform.Rotate(cannon.transform.right, -50, Space.World);
        float power;

        power = Random.Range(45, 65);
        if (!activeClock)
        {
            StartClock();
            cannon.shoot(power);
        }
    }
Beispiel #2
0
    // Update is called once per frame
    void Update()
    {
        float move = Input.GetAxis("Vertical");
        float h    = Input.GetAxis("Horizontal");

        if (mode == 0)
        {
            anim.SetFloat("Speed", move);
            anim.SetFloat("H", h);
            if (move < -0f)
            {
                anim.SetBool("Back", true);
                cur += Time.deltaTime;
                //anim.SetBool("Back", false);
                //print("Back true");
            }
            //print(cur);
            if (anim.GetBool("Back"))
            {
                cur += Time.deltaTime;
            }
            if (cur > 1.62f)
            {
                cur = cur - cur;
                anim.SetBool("Back", false);
                //print("This is not true");
            }

            mCam.transform.position = transform.position - 5 * transform.forward + 2 * Vector3.up;
            mCam.transform.forward  = transform.forward;
        }
        else if (mode == 1)
        {
            //print("Cannon aiming mode" + cannon.name);
            cannon.transform.Rotate(Vector3.up, h * rotateSpeed * Time.deltaTime, Space.World);
            cannon.transform.Rotate(cannon.transform.right, move * rotateSpeed * Time.deltaTime, Space.World);

            mCam.transform.position = cannon.spawnPoint.transform.position;
            mCam.transform.forward  = cannon.transform.forward;

            if (Input.GetButtonDown("Fire1"))
            {
                cannonBall = cannon.shoot(60);
                mode       = -1;
                Invoke("setFollowing", .25f);
            }
            if (Input.GetButtonDown("Fire2"))
            {
                setMoveMode();
            }
        }
        else if (mode == 2)
        {
            if (cannonBall != null)
            {
                mCam.transform.position = cannonBall.transform.position - cannonBall.velocity * 0.25f;
                mCam.transform.LookAt(cannonBall.transform.position);
            }
            else
            {
                mode = -1;
                if (cannon.gameObject == null)
                {
                    mCam.GetComponent <ExplosionController>().EndGame();
                }
                Invoke("setAimMode", 1);
            }
        }
        else
        {
            //null mode
        }
    }