// Use this for initialization void Start() { if (bikeController == null) { bikeController = GameObject.FindWithTag("Player").GetComponent <BikeControl>(); } }
void Update() { if(BikeScript == null) BikeScript = transform.GetComponent<BikeControl>(); nitroUI.width = (int)BikeScript.powerShift * 2; nitroUI.height = 50; //Debug.Log (BikeScript.powerShift); gearst = BikeScript.currentGear; thisAngle = (BikeScript.motorRPM / 20) - 175; thisAngle = Mathf.Clamp(thisAngle, -180, 90); Vector2 pos = new Vector2 (91, 91); // rotatepoint in texture plus x/y coordinates. our needle is at 16/16. Texture is 128/128. Makes middle 64 plus 16 = 80 arrowUI.transform.rotation = Quaternion.Euler(new Vector3(0f,0f,-thisAngle)); if (gearst > 0 && BikeScript.speed > 1) { gearstUI.text = gearst.ToString(); } else if (BikeScript.speed > 1) { gearstUI.text = "R"; } else { gearstUI.text = "N"; } speedUI.text = ((int)BikeScript.speed).ToString (); }
private IEnumerator UpdateMyPosition() { WaitForSeconds waitSec = new WaitForSeconds(0.5f); TrackGamePacket.PACKET_REQ_ROOM_UPDATE_PLAYER_POSITION update_packet = new TrackGamePacket.PACKET_REQ_ROOM_UPDATE_PLAYER_POSITION(); update_packet.Init(); update_packet.room_id = (short)RoomId; update_packet.player_index = (short)MyIndex; BikeControl speedGet = player_object.GetComponent <BikeControl>(); while (true) { //update_packet.x = player_object.transform.position.x; //update_packet.y = player_object.transform.position.z; //update_packet.z = player_object.transform.position.y; update_packet.v = speedGet.MoveSpeed; //update_packet.r = player_object.transform.rotation.y; trackUI.info[MyIndex].speed = speedGet.MoveSpeed; NetworkManager.Send(Utility.ToByteArray((object)update_packet)); yield return(waitSec); } yield return(0); }
void Update() { if (BikeScript == null) { BikeScript = transform.GetComponent <BikeControl>(); } nitroUI.width = (int)BikeScript.powerShift * 2; nitroUI.height = 50; //Debug.Log (BikeScript.powerShift); gearst = BikeScript.currentGear; thisAngle = (BikeScript.motorRPM / 20) - 175; thisAngle = Mathf.Clamp(thisAngle, -180, 90); Vector2 pos = new Vector2(91, 91); // rotatepoint in texture plus x/y coordinates. our needle is at 16/16. Texture is 128/128. Makes middle 64 plus 16 = 80 arrowUI.transform.rotation = Quaternion.Euler(new Vector3(0f, 0f, -thisAngle)); if (gearst > 0 && BikeScript.speed > 1) { gearstUI.text = gearst.ToString(); } else if (BikeScript.speed > 1) { gearstUI.text = "R"; } else { gearstUI.text = "N"; } speedUI.text = ((int)BikeScript.speed).ToString(); }
void Start() { data = GameData.Get(); lineOfSightMask = LayerMask.NameToLayer("Bike"); BikeScript = (BikeControl)target.GetComponent <BikeControl>(); bikeRot = BikeManager.instance.bikesContols [data.currentBike].transform.eulerAngles.x; }
public void StartRecord() { Debug.Log("Player Speed record start"); player_object = GameObject.FindWithTag("Player"); bikeController = player_object.GetComponent <BikeControl>(); update = true; StartCoroutine(UpdateRecord()); }
void Start() { data = GameData.Get (); BikeScript = myBike.GetComponent<BikeControl>(); animator = player.GetComponent<Animator>(); myPosition = player.localPosition; myRotation = player.localRotation; DisableRagdoll(true); }
// Use this for initialization void Start() { current_speed = 0; current_rpm = 0; speedData = new ANTRawData[2]; rpmData = new ANTRawData[2]; if (bikeController == null) { bikeController = GameObject.FindWithTag("Player").GetComponent <BikeControl>(); } try { dev0 = new ANT_Device(); dev0.deviceResponse += new ANT_Device.dDeviceResponseHandler(dev0_deviceResponse); dev0.getChannel(0).channelResponse += new dChannelResponseHandler(speedSensorResponse); dev0.getChannel(1).channelResponse += new dChannelResponseHandler(cadenceSensorResponse); dev0.setNetworkKey(0, new byte[] { 0xB9, 0xA5, 0x21, 0xFB, 0xBD, 0x72, 0xC3, 0x45 }); channel_speed = dev0.getChannel(0); channel_cadence = dev0.getChannel(1); channel_speed.assignChannel(ANT_ReferenceLibrary.ChannelType.BASE_Slave_Receive_0x00, 0, timeout); channel_speed.setChannelID(0, false, 123, 0, timeout); channel_speed.setChannelPeriod(8118, timeout); channel_speed.setChannelFreq(57, timeout); channel_speed.openChannel(timeout); channel_cadence.assignChannel(ANT_ReferenceLibrary.ChannelType.BASE_Slave_Receive_0x00, 0, timeout); channel_cadence.setChannelID(0, false, 122, 0, timeout); channel_cadence.setChannelPeriod(8102, timeout); channel_cadence.setChannelFreq(57, timeout); channel_cadence.openChannel(timeout); StartCoroutine(UpdateCoroutine()); StartCoroutine(WaitForDecreaseSpeed()); StartCoroutine(DecreaseSpeed()); bikeController.is_ant_used = true; } catch (System.Exception) { bikeController.is_ant_used = false; } finally { } Debug.Log("ANT Reset : " + bikeController.is_ant_used); }
void Start() { data = GameData.Get(); BikeScript = myBike.GetComponent <BikeControl>(); animator = player.GetComponent <Animator>(); myPosition = player.localPosition; myRotation = player.localRotation; DisableRagdoll(true); }
void setBikeProperties() { BikeControl targetBike = bikesContols[data.currentBike]; cam.target = targetBike.transform; cam.BikeScript = targetBike; targetBike.transform.GetComponent <BikeGUI> ().enabled = true; targetBike.gameObject.SetActive(true); Transform[] positionView = { targetBike.transform.FindChild("Components").FindChild("ForestView").FindChild("View-2").transform /*, * targetBike.FindChild("Components").FindChild("ForestView").FindChild("View-3").transform*/}; cam.cameraSwitchView = positionView; }
void setBikeProperties() { BikeControl targetBike = bikesContols[data.currentBike]; cam.target = targetBike.transform; cam.BikeScript = targetBike; CarAI.motik = cam.target; targetBike.rigidbody.isKinematic = false; targetBike.transform.GetComponent <BikeGUI> ().enabled = true; targetBike.gameObject.SetActive(true); Transform[] positionView = { targetBike.transform.FindChild("Components").FindChild("ForestView").FindChild("View-1").transform, targetBike.transform.FindChild("Components").FindChild("ForestView").FindChild("View-2").transform, targetBike.transform.FindChild("Components").FindChild("ForestView").FindChild("View-3").transform }; cam.cameraSwitchView = positionView; }
void OnTriggerStay(Collider other) { if (other.CompareTag("HandleTrigger")) { GameControl.manager.getInVehicle.SetActive(true); if ((GameControl.manager.controlMode == ControlMode.simple && Input.GetKey(KeyCode.F)) || (GameControl.manager.controlMode == ControlMode.touch && GameControl.driving == true)) { if (other.transform.root.GetComponent <CarComponents>()) { carComponents = other.transform.root.GetComponent <CarComponents>(); m_AIVehicle = other.transform.root.GetComponent <AIVehicle>(); m_VehicleControl = other.transform.root.GetComponent <VehicleControl>(); door = carComponents.door; handleTrigger = carComponents.handleTrigger; sitPoint = carComponents.sitPoint; gettingOnCar = true; gettingOnBike = false; GameControl.manager.getInVehicle.SetActive(false); } if (other.transform.root.GetComponent <BikeComponents>()) { bikeComponents = other.transform.root.GetComponent <BikeComponents>(); m_AIVehicle = other.transform.root.GetComponent <AIVehicle>(); m_BikeControl = other.transform.root.GetComponent <BikeControl>(); handleTrigger = bikeComponents.handleTrigger; sitPoint = bikeComponents.sitPoint; gettingOnBike = true; gettingOnCar = false; GameControl.manager.getInVehicle.SetActive(false); } } } }
IEnumerator PositionUpdateRoutine() { yield return(new WaitForSeconds(10.0f)); float x = 0.0f, y = 0.0f, r = 0.0f, v = 0.0f; PACKET_REQ_PLAYER_MOVE movePacket = new PACKET_REQ_PLAYER_MOVE(); movePacket.Init(); BikeControl bike = player_object.GetComponent <BikeControl>(); while (true) { v = bike.MoveSpeed; movePacket.x = bike.GetDistance(); //movePacket.y = player_object.transform.position.z; movePacket.v = v; //movePacket.r = r; if (v >= 1.0) { byte[] data = Utility.ToByteArray((object)movePacket); /* * REMIND : ToByteArray는 아마도 오버헤드를 많이 먹을 것이므로 일단 임시로 이렇게 해둔 다음에, * 바이트 배열에 직접 x,y,r,v를 집어넣는 식으로 바꾸는걸 고려해보자. */ NetworkManager.Send(data); } yield return(new WaitForSeconds(1.0f)); } yield return(null); }
void Start() { lineOfSightMask = LayerMask.NameToLayer("Bike"); BikeScript = (BikeControl)target.GetComponent<BikeControl>(); }
void Start() { BikeScript = transform.GetComponent <BikeControl>(); }
void Awake() { instance = this; data = GameData.Get (); //TODO: remove this string if need to have different default bike on game start //data.currentBike = 0; if(data.currentLvl % 2 == 0) bikePositions = positionsWrapers[0]; else bikePositions = positionsWrapers[1]; cam.distance = cameraDistance; cam.haight = cameraHeight; cam.Angle = cameraAngle; bikesContols = new List<BikeControl> (); if(GameObject.Find("Motorbike Extra") != null) { extrabike = GameObject.Find("Motorbike Extra").GetComponent<BikeControl>(); BikeGUI bikeGui= extrabike.gameObject.GetComponent<BikeGUI>(); bikeGui.arrowUI = arrowUI; bikeGui.speedUI = speedUI; bikeGui.gearstUI = gearstUI; bikeGui.nitroUI = nitroUI; Transform pos = bikePositions.FindChild("Position Extra").transform; extrabike.rigidbody.velocity = Vector3.zero; extrabike.transform.position = pos.position ; extrabike.transform.rotation = pos.rotation; extrabike.currentGear = 1; extrabike.curTorque = 0f; extrabike.shiftDelay = 0f; extrabike.gameObject.SetActive(false); } for(int i = 0; i < bikePositions.childCount; i++) { if(GameObject.Find("Motorbike "+(i+1).ToString()) == null) continue; GameObject b = GameObject.Find("Motorbike "+(i+1).ToString()); BikeControl bikeControl = b.GetComponent<BikeControl>(); bikesContols.Add(bikeControl); BikeGUI bikeGui= b.GetComponent<BikeGUI>(); bikeGui.arrowUI = arrowUI; bikeGui.speedUI = speedUI; bikeGui.gearstUI = gearstUI; bikeGui.nitroUI = nitroUI; Transform pos = bikePositions.FindChild("Position "+(i+1).ToString()).transform; b.rigidbody.velocity = Vector3.zero; b.transform.position = pos.position ; b.transform.rotation = pos.rotation; bikeControl.currentGear = 1; bikeControl.curTorque = 0f; bikeControl.shiftDelay = 0f; b.SetActive(false); } if(data.extraBike) { bikesContols.Add(extrabike); } setBikeProperties (); }
void Start() { BikeScript = transform.GetComponent<BikeControl>(); }
void Awake() { data = GameData.Get(); //TODO: remove this string if need to have different default bike on game start data.currentBike = 0; if (data.currentLvl % 2 == 0) { bikePositions = positionsWrapers[0]; } else { bikePositions = positionsWrapers[1]; } cam.distance = cameraDistance; cam.haight = cameraHeight; cam.Angle = cameraAngle; bikesContols = new List <BikeControl> (); if (GameObject.Find("Motorbike Extra") != null) { extrabike = GameObject.Find("Motorbike Extra").GetComponent <BikeControl>(); BikeGUI bikeGui = extrabike.gameObject.GetComponent <BikeGUI>(); bikeGui.arrowUI = arrowUI; bikeGui.speedUI = speedUI; bikeGui.gearstUI = gearstUI; bikeGui.nitroUI = nitroUI; Transform pos = bikePositions.FindChild("Position Extra").transform; extrabike.rigidbody.velocity = Vector3.zero; extrabike.transform.position = pos.position; extrabike.transform.rotation = pos.rotation; extrabike.currentGear = 1; extrabike.curTorque = 0f; extrabike.shiftDelay = 0f; extrabike.gameObject.SetActive(false); } for (int i = 0; i < bikePositions.childCount; i++) { if (GameObject.Find("Motorbike " + (i + 1).ToString()) == null) { continue; } GameObject b = GameObject.Find("Motorbike " + (i + 1).ToString()); BikeControl bikeControl = b.GetComponent <BikeControl>(); bikesContols.Add(bikeControl); BikeGUI bikeGui = b.GetComponent <BikeGUI>(); bikeGui.arrowUI = arrowUI; bikeGui.speedUI = speedUI; bikeGui.gearstUI = gearstUI; bikeGui.nitroUI = nitroUI; Transform pos = bikePositions.FindChild("Position " + (i + 1).ToString()).transform; b.rigidbody.velocity = Vector3.zero; b.transform.position = pos.position; b.transform.rotation = pos.rotation; bikeControl.currentGear = 1; bikeControl.curTorque = 0f; bikeControl.shiftDelay = 0f; b.SetActive(false); } if (data.extraBike) { bikesContols.Add(extrabike); } setBikeProperties(); }
public void OnInspectorGUI() { BikeControl myPlayer = (BikeControl)target; }
void Start() { lineOfSightMask = LayerMask.NameToLayer("Bike"); BikeScript = (BikeControl)target.GetComponent <BikeControl>(); }