void OnGUI() { if(controlType == ControlType.Full) { GUI.DrawTexture(new Rect(Screen.width/2 - targetSize/2,Screen.height/2 - targetSize/2,targetSize,targetSize),target); if(GUI.Button(new Rect(Screen.width/25,5,missileButtonWidth - 10,missileButtonHeight),"M1")) { if(tLC == null) { tLC = transform.parent.GetComponentInChildren<topLevelController>(); if(tLC != null) { fireMissile(missileType.Homing); } } else { fireMissile(missileType.Homing); } } if(GUI.Button(new Rect(Screen.width/25 + missileButtonWidth,5,missileButtonWidth - 10,missileButtonHeight),"M2")) { if(tLC == null) { tLC = transform.parent.GetComponentInChildren<topLevelController>(); if(tLC != null) { fireMissile(missileType.Controlled); } } else { fireMissile(missileType.Controlled); } } } }
// Update is called once per frame void Update() { if(delaying) delaycount -= Time.deltaTime; if(delaycount <= 0) delaying=false; if(tLC == null) { tLC = transform.parent.GetComponentInChildren<topLevelController>(); } if(controlType == ControlType.Full && !justActivated) { float yAngle = Mathf.Asin(transform.parent.forward.y/Mathf.Abs(transform.parent.forward.magnitude)); Collider[] cols = Physics.OverlapSphere(transform.position, 150); foreach (Collider hit in cols){ if((hit.gameObject.name == "AIContMissile(Clone)" || hit.gameObject.name == "homingMissileRedo(Clone)" || hit.gameObject .name == "ControlledMissile(Clone)")) { GameObject closeobject = hit.gameObject; if(closeobject.tag.CompareTo(""+tLC.teamNum)!=0) { if(!warn) PlayAudioClip(warning, transform.position, 2f); warn = true; break; } } } if(warn) { playcount++; if(playcount>=400) { warn=false; playcount=0; } } if (tLC.currentMissileSelection==5) { lineRenderer.enabled = true; int max=200; int v; Vector3 pos = transform.parent.position+transform.forward*20; Vector3 vel = transform.forward*Bomb.projectilespeed + Bomb.initialVelocityOffset; lineRenderer.SetVertexCount(max); float dt = Time.fixedDeltaTime; for (v=0; v < max && pos.y>0; v++) { vel += Bomb.gravity*Vector3.down*dt; pos += vel*dt; lineRenderer.SetPosition(v,pos); } lineRenderer.SetVertexCount(v); } else{ lineRenderer.enabled = false; } if(Input.GetMouseButtonDown(0)) { fireMissile(tLC.currentMissileSelection); } else if(Input.GetMouseButtonDown(1)) { tLC.openMiniScreen(tLC.currentMissileSelection); } else if(Input.GetMouseButtonDown(2)) { if(tLC == null) { tLC = transform.parent.GetComponentInChildren<topLevelController>(); if(tLC != null) { cleanUpOnExit(); tLC.moveToThirdPerson(); } } else { cleanUpOnExit(); tLC.moveToThirdPerson(); } } if(Input.GetKeyDown(KeyCode.Tab)) { tLC.manager.scrollFromTab(); } float scrollValue = Input.GetAxis("Mouse ScrollWheel"); scrollValue = scrollValue*10; if(scrollValue != 0) { tLC.scrollMissileSelection(Mathf.RoundToInt(scrollValue)); } else if(Input.GetKeyDown(KeyCode.P)) { tLC.scrollMissileSelection(1); } else if(Input.GetKeyDown(KeyCode.O)) { tLC.scrollMissileSelection(-1); } if(Input.GetKey(KeyCode.LeftArrow) || Input.GetKey(KeyCode.A)) { transform.parent.RotateAroundLocal(Vector3.up,-Mathf.PI*Time.deltaTime/20); } else if(Input.GetKey(KeyCode.RightArrow) || Input.GetKey(KeyCode.D)) { transform.parent.RotateAroundLocal(Vector3.up,Mathf.PI*Time.deltaTime/20); } if((Input.GetKey(KeyCode.UpArrow) || Input.GetKey(KeyCode.W)) && yAngle < Mathf.PI/8) { transform.parent.RotateAroundLocal(transform.right,-Mathf.PI*Time.deltaTime/20); } else if((Input.GetKey(KeyCode.DownArrow) || Input.GetKey(KeyCode.S)) && yAngle > -Mathf.PI/8) { transform.parent.RotateAround(transform.right,Mathf.PI*Time.deltaTime/20); } float y = Input.GetAxis("Mouse Y"); float x = Input.GetAxis("Mouse X"); transform.parent.Rotate(new Vector3(-y, 0, 0) * Time.deltaTime * 50); transform.parent.Rotate(new Vector3(0, x, 0) * Time.deltaTime * 50); transform.parent.eulerAngles = new Vector3(transform.parent.eulerAngles.x,transform.parent.eulerAngles.y, 0); if(Input.GetKeyDown(KeyCode.Q)) { if(tLC == null) { tLC = transform.parent.GetComponentInChildren<topLevelController>(); if(tLC != null) { cleanUpOnExit(); tLC.moveToThirdPerson(); } } else { cleanUpOnExit(); tLC.moveToThirdPerson(); } //TODO implement the rest of switching to the other camera } } else if(justActivated) { justActivated = false; } }
// Update is called once per frame void Update() { if(controlType == ControlType.Full && !justActivated) { float yAngle = Mathf.Asin(transform.parent.forward.y/Mathf.Abs(transform.parent.forward.magnitude)); if(Input.GetKeyDown(KeyCode.Alpha1)) { if(tLC == null) { tLC = transform.parent.GetComponentInChildren<topLevelController>(); if(tLC != null) { if(Input.GetKey(KeyCode.LeftShift)) { tLC.openMiniScreen(0); } else { fireMissile(missileType.Homing); } } } else { if(Input.GetKey(KeyCode.LeftShift)) { tLC.openMiniScreen(0); } else { fireMissile(missileType.Homing); } } } if(Input.GetKeyDown(KeyCode.Alpha2)) { if(tLC == null) { tLC = transform.parent.GetComponentInChildren<topLevelController>(); if(tLC != null) { if(Input.GetKey(KeyCode.LeftShift)) { tLC.openMiniScreen(1); } else { fireMissile(missileType.Controlled); } } } else { if(Input.GetKey(KeyCode.LeftShift)) { tLC.openMiniScreen(1); } else { fireMissile(missileType.Controlled); } } } if(Input.GetKey(KeyCode.LeftArrow) || Input.GetKey(KeyCode.A)) { transform.parent.RotateAroundLocal(Vector3.up,-Mathf.PI*Time.deltaTime/20); } else if(Input.GetKey(KeyCode.RightArrow) || Input.GetKey(KeyCode.D)) { transform.parent.RotateAroundLocal(Vector3.up,Mathf.PI*Time.deltaTime/20); } if((Input.GetKey(KeyCode.UpArrow) || Input.GetKey(KeyCode.W)) && yAngle < Mathf.PI/8) { transform.parent.RotateAroundLocal(transform.right,-Mathf.PI*Time.deltaTime/20); } else if((Input.GetKey(KeyCode.DownArrow) || Input.GetKey(KeyCode.S)) && yAngle > -Mathf.PI/8) { transform.parent.RotateAround(transform.right,Mathf.PI*Time.deltaTime/20); } float y = Input.GetAxis("Mouse Y"); float x = Input.GetAxis("Mouse X"); transform.parent.Rotate(new Vector3(-y, 0, 0) * Time.deltaTime * 50); transform.parent.Rotate(new Vector3(0, x, 0) * Time.deltaTime * 50); transform.parent.eulerAngles = new Vector3(transform.parent.eulerAngles.x,transform.parent.eulerAngles.y, 0); if(Input.GetKeyDown(KeyCode.Q)) { if(tLC == null) { tLC = transform.parent.GetComponentInChildren<topLevelController>(); if(tLC != null) { cleanUpOnExit(); tLC.moveToThirdPerson(); } } else { cleanUpOnExit(); tLC.moveToThirdPerson(); } //TODO implement the rest of switching to the other camera } } else if(justActivated) { justActivated = false; } }
// Update is called once per frame void Update() { if(tLC == null) { tLC = transform.parent.GetComponentInChildren<topLevelController>(); } if(controlType == ControlType.Full && !justActivated) { float yAngle = Mathf.Asin(transform.parent.forward.y/Mathf.Abs(transform.parent.forward.magnitude)); if(Input.GetKey(KeyCode.LeftArrow) || Input.GetKey(KeyCode.A)) { transform.parent.RotateAroundLocal(Vector3.up,-Mathf.PI*Time.deltaTime/5); } else if(Input.GetKey(KeyCode.RightArrow) || Input.GetKey(KeyCode.D)) { transform.parent.RotateAroundLocal(Vector3.up,Mathf.PI*Time.deltaTime/5); } if((Input.GetKey(KeyCode.UpArrow) || Input.GetKey(KeyCode.W)) && yAngle < Mathf.PI/8) { transform.parent.RotateAroundLocal(transform.right,-Mathf.PI*Time.deltaTime/5); } else if((Input.GetKey(KeyCode.DownArrow) || Input.GetKey(KeyCode.S)) && yAngle > -Mathf.PI/8) { transform.parent.RotateAround(transform.right,Mathf.PI*Time.deltaTime/5); } float y = Input.GetAxis("Mouse Y"); float x = Input.GetAxis("Mouse X"); transform.parent.Rotate(new Vector3(-y, 0, 0) * Time.deltaTime * 50); transform.parent.Rotate(new Vector3(0, x, 0) * Time.deltaTime * 50); transform.parent.eulerAngles = new Vector3(transform.parent.eulerAngles.x,transform.parent.eulerAngles.y, 0); if(Input.GetMouseButtonDown(0)) { if(tLC.moveToMissile(tLC.currentMissileSelection)) { cleanUpOnExit(); } } if(Input.GetMouseButtonDown(1)) { if(tLC == null) { tLC = transform.parent.GetComponentInChildren<topLevelController>(); } tLC.openMiniScreen(tLC.currentMissileSelection); } if(Input.GetKeyDown(KeyCode.Q) || Input.GetMouseButtonDown(2)) { if(tLC == null) { tLC = transform.parent.GetComponentInChildren<topLevelController>(); if(tLC != null) { cleanUpOnExit(); tLC.moveToFirstPerson(); } } else { cleanUpOnExit(); tLC.moveToFirstPerson(); } //TODO implement the rest of switching to the other camera } int scroll = Mathf.RoundToInt(Input.GetAxis("Mouse ScrollWheel") * 10.0f); if (scroll!=0) { print("scrolling "+scroll); tLC.manager.scroll(scroll); } if(Input.GetKeyDown(KeyCode.Tab)) tLC.manager.scroll(1); } else if(justActivated) { justActivated = false; } //transform.forward = targetPosition - transform.position; if(angle >= Mathf.PI*2) { angle -= Mathf.PI*2; } else if(angle <= Mathf.PI*2) { angle += Mathf.PI*2; } }