// Update is called once per frame
 void Update()
 {
     shipControls = gameManager.prefabManager.currentPrefab.GetComponent <ShipControls>();
     tankControls = gameManager.prefabManager.currentPrefab.GetComponent <SimpleTankController>();
     //if (currentDialog == null) showDialog = false;
     if (Input.GetKeyDown(KeyCode.Space) && showDialog)
     {
         // nextDialog = currentDialog.nextDialog;
         previousDialog = currentDialog;
         if (currentDialog.keepParentSize)
         {
             parentRect = new Rect(currentDialog.position.x, currentDialog.position.y, currentDialog.size.x, currentDialog.size.y);
         }
         currentDialog = nextDialog;
         if (nextDialog == null || currentDialog == null)
         {
             showDialog = false;
         }
     }
 }
示例#2
0
    // Update is called once per frame
    void Update()
    {
        ShipControls         shipControls   = prefabManager.currentPrefab.GetComponent <ShipControls>();
        SimpleTankController tankController = prefabManager.currentPrefab.GetComponent <SimpleTankController>();

        if (shipControls != null)
        {
            projectileData = shipControls.shipWeapon.projectile.GetComponent <Projectile>();
        }
        if (tankController != null)
        {
            projectileData = tankController.groundWeapon.projectile.GetComponent <Projectile>();
        }

        /*if (Input.GetKeyDown (KeyCode.Q)) {
         *  shoot = !shoot;
         *  GameObject.Find ("UIManager").GetComponent<SelectionUI> ().target = null;
         * }*/
        //if (GameObject.Find("UIManager").GetComponent<SelectionUI>().target != null)
        //{
        //float _angle = myGetAngle (frontMount.position, GameObject.Find ("UIManager").GetComponent<SelectionUI> ().target.transform.position);

        //projectileOrigin.LookAt (GameObject.Find ("UIManager").GetComponent<SelectionUI> ().target.transform);

        //if (GameObject.Find("UIManager").GetComponent<SelectionUI>().target){
        // facingFront = IsFacingObject(frontMount, GameObject.Find("UIManager").GetComponent<SelectionUI>().target.transform);
        // facingRear = IsFacingObject(rearMount, GameObject.Find("UIManager").GetComponent<SelectionUI>().target.transform);

        //bool facingLeft = IsFacingObject (leftMount, GameObject.Find ("UIManager").GetComponent<SelectionUI> ().target.transform);
        //bool facingRight = IsFacingObject (rightMount, GameObject.Find ("UIManager").GetComponent<SelectionUI> ().target.transform);
        //shoot = false;

        // if (facingFront)
        // {
        // projectileOrigin = frontMount;
        // // projectileOrigin.LookAt (GameObject.Find ("UIManager").GetComponent<SelectionUI> ().target.transform);
        // direction = projectileOrigin.forward;
        //facingFront = false;
        //shoot = true;
        //     }
        //      if (facingRear)
        //     {
        //         projectileOrigin = rearMount;
        //      projectileOrigin.LookAt (GameObject.Find ("UIManager").GetComponent<SelectionUI> ().target.transform);
        //         direction = projectileOrigin.forward;
        //      facingRear = false;
        //         //shoot = true;
        //     }
        // } else {
        projectileOrigin = frontMount;
        //projectileOrigin.rotation = new Quaternion(0, 0, 0, 0);
        //facingFront = false;
        //facingRear = false;
        direction = projectileOrigin.forward;
        //}
        //if (GameObject.Find ("GameManager").GetComponent<GameManager> ().playerLocation == GameDataTypes.locationType.Air) direction = Vector3.down;

        //}
        if (Input.GetKeyDown(KeyCode.Period))
        {
            //if (GameObject.Find("UIManager").GetComponent<SelectionUI>().target != null)
            //{
            //Transform temp = projectileOrigin;
            //temp.LookAt (GameObject.Find ("UIManager").GetComponent<SelectionUI> ().target.transform);
            GameObject bullet = Instantiate(weapon.projectile.gameObject, projectileOrigin.position + direction, projectileOrigin.rotation) as GameObject;

            //bullet.GetComponent<Rigidbody> ().velocity = transform.TransformDirection (GameObject.Find ("UIManager").GetComponent<SelectionUI> ().target.transform.position) * projectileData.speed;

            //projectileOrigin.LookAt (GameObject.Find ("UIManager").GetComponent<SelectionUI> ().target.transform);
            bullet.GetComponent <Rigidbody>().AddForce(projectileOrigin.forward * projectileData.speed);
            //facingRear = false;
            //facingFront = false;
            //projectileOrigin.transform.rotation = Quaternion.identity;
            Destroy(bullet.gameObject, 25f);
            //}

            /* else {
             *              projectileOrigin.LookAt (Vector3.up);
             *              bullet.GetComponent<Rigidbody> ().AddForce (transform.forward * projectileData.speed);
             *          }*/
        }
    }