private CatapultScript minigameScript; // script for the catapult // Use this for initialization void Start() { // display all the tuturial parts blur.SetActive(true); minigameScript = minigame.GetComponent <CatapultScript>(); minigameScript.tutorialActive = true; }
// Update is called once per frame void Update() { Vector3 weaponSpawnPoint = new Vector3(xValue, Random.Range(-minY, maxY), weapon.transform.position.z); Vector3 moveToward; if (canFire) { if (Input.GetButton("Fire1")) { moveToward = Camera.main.ScreenToWorldPoint(Input.mousePosition); moveToward.z = 0; moveDirection = moveToward - weaponSpawnPoint; moveDirection.Normalize(); Quaternion rotation = Quaternion.Euler(0, 0, Mathf.Atan2(-moveDirection.y, -moveDirection.x) * Mathf.Rad2Deg); if (arrowOn) { GameObject arrow = Instantiate(weapon, weaponSpawnPoint, rotation) as GameObject; ArrowScript arrowScript = arrow.GetComponent <ArrowScript>(); arrowScript.moveDirection = moveDirection; } else { GameObject catapult = Instantiate(weapon, weaponSpawnPoint, rotation) as GameObject; CatapultScript catapultScript = catapult.GetComponent <CatapultScript>(); catapultScript.moveDirection = moveDirection; } holdFire(); Invoke("openFire", weaponFireRate); } } }
private void Start() { cs = GetComponentInParent <CatapultScript>(); ballSpeed = cs.startSpeed; if (ballSpeed < 0) { ballSpeed = -ballSpeed; } }
//private float compassSampleSum = 0; // Use this for initialization void Start() { catScr = myCatapult.GetComponent <CatapultScript> (); //transform.parent = GameObject.Find ("SceneCenter").transform; if (!isLocalPlayer) { //if (!isServer) { pillGuy = Instantiate(pillGuyObject); pillGuy.GetComponent <PillGuyMovement> ().myTablet = tablet.transform.gameObject; //} catScr.amLocal = false; Destroy(myCamObj); return; } makeGuiObj(); trackScript = GameObject.Find("SceneCenter").GetComponent <MultiTrackingScript> (); catScr.setLocalProperties(); camera = GameObject.Find("SceneCamera"); background = GameObject.Find("BackgroundPlane"); Vector3 storePos = background.transform.localPosition; Quaternion storeRot = background.transform.localRotation; background.transform.parent = myCamObj.transform; background.transform.localPosition = storePos; background.transform.localRotation = storeRot; myCam = myCamObj.GetComponent <Camera> (); camera.GetComponent <Camera> ().enabled = false; myCam.enabled = true; gps = GetComponent <GPSScript> (); //Spawn a catapult //myCatapult = Instantiate (catapult); //myCatapult.transform.parent = transform; //myCatapult.transform.localPosition = Vector3.zero; //myCatapult.transform.localRotation = Quaternion.identity; catScr.camera = myCam; string offGuiStr = GameObject.Find("OffsetGui").GetComponent <OffsetGuiScript>().offset; Destroy(GameObject.Find("OffsetGui")); string[] strs = offGuiStr.Split(new string[] { "," }, StringSplitOptions.None); if (strs.Length == 2) { OffsetProvided = true; offset = new Vector3(int.Parse(strs [0]), 0, int.Parse(strs [1])); } //compassStartTime = Time.time; }