// the mouse position which the ship needs to face // private Vector3 heading; private void Awake() { // initalization stuff rb = gameObject.GetComponent <Rigidbody>(); //heading = new Vector3(); scanner = gameObject.GetComponent <ScannerScript>(); mc = gameObject.GetComponent <MovementController>(); Cursor.lockState = CursorLockMode.Locked; }
void Update() { qr_scanner = gameObject.GetComponent <ScannerScript> (); if (qr_scanner != null) { cameraDisplay.texture = qr_scanner.CameraTexture; if (qr_scanner.Result != null) //We got a QR code from the scanner { Debug.Log("ScannerOverlayScript: Got result from QR Scanner " + qr_scanner.Result); //Start the coroutine for downloading the card StartCoroutine(IDecodeCard((string)qr_scanner.Result)); Destroy(qr_scanner); } } //Check if we have decoded/downloading some data from the cloud if (downloadResult != null) { Sprite displayPicture = null; string displayText = null; ui_card_text.color = Color.white; if (downloadResult is Monster) { Debug.Log("ScannerOverlayScript: Downloaded a Monster Card"); Debug.Log("Monster Card: " + ((Monster)downloadResult).Name); displayPicture = ((Monster)downloadResult).Image; displayText = ((Monster)downloadResult).OutputCardDetails(); } else if (downloadResult is Card) { Debug.Log("ScannerOverlayScript: Downloaded a Spell/Trap Card"); Debug.Log("Spell/Trap Card: " + ((Card)downloadResult).Name); displayPicture = ((Card)downloadResult).Image; displayText = ((Card)downloadResult).OutputCardDetails(); } else { Debug.LogWarning("ScannerOverlayScript: Got something other " + "than what is normally gotten from the cloud"); ui_card_text.color = Color.red; displayText = "Invalid Card Code..."; } ui_card_image.sprite = displayPicture; ui_card_text.text = displayText; ui_panel_camera.SetActive(false); ui_panel_data.SetActive(true); downloadResult = null; } }
void Update() { //Check to see if the QRCode Scanner is running qr_scanner = gameObject.GetComponent <ScannerScript> (); if (qr_scanner != null) //If it is running //Assign the camera input to the correct UI object { ui_cameraDisplay.texture = qr_scanner.CameraTexture; if (qr_scanner.Result != null) //We got a QR code from the scanner { Debug.Log("ScannerOverlayScript: Got result from QR Scanner " + qr_scanner.Result); //Start the coroutine for downloading the card StartCoroutine(IDecodeCard((string)qr_scanner.Result)); Destroy(qr_scanner); } } //Check to see what we have recieved from the download manager if (downloadResult != null) { if (downloadResult is Monster) { Debug.Log("DuelCardScannerScript: Got a monster card"); Debug.Log("Monster Card: " + ((Monster)downloadResult).Name); img_MonsterAttack.sprite = ((Monster)downloadResult).Image; img_MonsterDefence.sprite = ((Monster)downloadResult).Image; ui_lblMonsterName.text = ((Monster)downloadResult).Name; ui_scanner.SetActive(false); ui_monsterPanel.SetActive(true); temp = (Monster)downloadResult; } else if (downloadResult is Card) { Debug.Log("DuelCardScannerScript: Got a spell card"); Debug.Log("Spell/Trap Card: " + ((Card)downloadResult).Name); img_SpellActive.sprite = ((Card)downloadResult).Image; ui_lblSpellName.text = ((Card)downloadResult).Name; ui_scanner.SetActive(false); ui_spellPanel.SetActive(true); temp = (Card)downloadResult; } else { Debug.LogWarning("DuelCardScannerScript: Did not find a card"); glob_gamemanager.SendMessage("DisplayErrorMessage", "Could not get the card data"); } downloadResult = null; } }
/// <summary> /// Method that will cancel and close the entire card scanning overlay /// and components. Resets everything back /// </summary> public void btn_CloseOverlay() { glob_audiomanager.SendMessage("PlayClickA"); if (qr_scanner != null) { Destroy(qr_scanner); } qr_scanner = null; ui_panel_camera.SetActive(true); ui_panel_data.SetActive(false); ui_accountOverlay.SetActive(true); gameObject.SetActive(false); }
private void Awake() { this.targets = new List <GameObject>(); this.PlayerTransform = GameObject.FindGameObjectWithTag(Resources.Tags.Player).transform; this.animator = GetComponent <Animator>(); #region get reference to the trigger collider SphereCollider[] colliders = GetComponents <SphereCollider>(); for (int i = 0; i < colliders.Length; i++) { if (colliders[i].isTrigger) { this.detectionCollider = colliders[i]; break; } } #endregion //this.SignalLight = GetComponentInChildren<DroneSignalLight>(); this.ScannerScript = this.ScannerTransform.gameObject.GetComponent <ScannerScript>(); #region set drone alarm and engine sounds this.droneAlarmAudioSource = this.gameObject.AddComponent <AudioSource>(); this.droneAlarmAudioSource.volume = 0.6f; this.droneAlarmAudioSource.loop = false; this.droneAlarmAudioSource.playOnAwake = false; this.droneAlarmAudioSource.clip = this.AlarmSound; this.droneAlarmAudioSource.spatialBlend = 0f; this.droneEngineAudioSource = this.gameObject.AddComponent <AudioSource>(); this.droneEngineAudioSource.spatialBlend = 1f; this.droneEngineAudioSource.minDistance = 20f; this.droneEngineAudioSource.maxDistance = 100f; this.droneEngineAudioSource.loop = true; this.droneEngineAudioSource.playOnAwake = false; this.droneEngineAudioSource.clip = this.EngineSound; this.droneEngineAudioSource.Play(); #endregion this.batteryLevel = this.MaxBatteryLevel; this.DroneBatterySlider.minValue = 0; this.DroneBatterySlider.maxValue = this.MaxBatteryLevel; this.DroneBatterySlider.value = this.MaxBatteryLevel; }
/// <summary> /// Closes the game object safely. Shuts down the camera and decoding /// thread /// </summary> private void CloseSafely() { if (qr_scanner != null) //If we have the QRCode scanner running //destroy it! { Destroy(qr_scanner); } //Reset all variables and displays qr_scanner = null; ui_scanner.SetActive(true); ui_monsterPanel.SetActive(false); ui_spellPanel.SetActive(false); gameObject.SetActive(false); //Hide this object nows }