// Use this for initialization void Start() { levelBeacon = GameObject.FindGameObjectWithTag("Beacon").GetComponent <MovableBeacon> (); wasFocus = false; FPCamera = GameObject.FindGameObjectWithTag("Player").GetComponentInChildren <Camera> (); templateImage = ImageHelper.ToImage(templateImageTexture); mask = ImageHelper.ToImage(maskTexture); startTime = Time.time; //sender = GetComponent<SendFeedback> (); }
// Update is called once per frame private void Update() { RotateView(); if (Holding != null && Holding as MovableBeacon == null) { bool RDown = CrossPlatformInputManager.GetButtonDown("ToggleRotate"); if (!WasHoldingRDown && RDown) { RotateMode = !RotateMode; overlayEffect.RotateEffect(RotateMode); print("rotate Toggle!"); } WasHoldingRDown = RDown; } // the jump state needs to read here to make sure it is not missed if (!Jump) { Jump = CrossPlatformInputManager.GetButtonDown("Jump"); } if (!PreviouslyGrounded && CharacterController.isGrounded) { StartCoroutine(JumpBob.DoBobCycle()); PlayLandingSound(); MoveDir.y = 0f; Jumping = false; } if (!CharacterController.isGrounded && !Jumping && PreviouslyGrounded) { MoveDir.y = 0f; } PreviouslyGrounded = CharacterController.isGrounded; Movable movingScript = null; RaycastHit hitInfo; if (Physics.Raycast(Camera.transform.position, Camera.transform.forward, out hitInfo, holdingDistance)) { GameObject aming = hitInfo.collider.gameObject; movingScript = aming.GetComponentInParent <Movable> (); } overlayEffect.AimActive(movingScript != null && Holding == null); bool holdIsDown = CrossPlatformInputManager.GetButtonDown("Hold"); //if not pressing e previous frame, but is now if (!WasHoldingHoldDown && holdIsDown) { if (Holding == null) { if (movingScript != null) { Holding = movingScript; WalkSpeed = Holding.Pickup(transform.position) ? 0.5f : OriginalSpeed; MovableBeacon beacon = Holding as MovableBeacon; if (beacon != null) { beacon.Inactivate(); } print("Pickup"); overlayEffect.HoldEffect(); } } else { WalkSpeed = OriginalSpeed; MovableBeacon beacon = Holding as MovableBeacon; if (beacon != null) { overlayEffect.CorrectEffect(beacon.LetGo(transform.position)); } else { overlayEffect.CorrectEffect(Holding.LetGo()); } Holding = null; RotateMode = false; print("LetDown"); } } WasHoldingHoldDown = holdIsDown; }