示例#1
0
    protected virtual void HandAttachedUpdate(Hand hand)
    {
        HandControls hc = ControlsManager.Instance.GetControlsFromHand(hand);

        //Highlight currently hovered over control
        //Do we want a more intense highlight for when we press over a sector?

        //Why not use Down? Becuase when we switch weapons, down is already called
        //but the control wheel isn't displayed
        if (hc.TouchPadTouched.Held || hc.TouchPadPressed.Held)
        {
            controlWheel.HighlightSectionAtLocation(hc.TouchPadLocation);

            if (isDisplaying == false)
            {
                controlWheel.DisplayControlWheel();
                isDisplaying = true;
            }
        }

        //Hide control wheel when not longer touched
        if (hc.TouchPadTouched.Up)
        {
            controlWheel.HideControlWheel();
            isDisplaying = false;
        }

        //On pressed, we active a section
        if (hc.TouchPadPressed.Up)
        {
            controlWheel.Select(hc.TouchPadLocation);
        }
    }
 #pragma warning restore 414
 
 
 void Awake( )
 {
    #if !(UNITY_FLASH)
    useGUILayout = false;
    #endif
    ExposedVariables.Awake( );
    ExposedVariables.SetParent( this.gameObject );
    if ( "1.PLE" != uScript_MasterComponent.Version )
    {
       uScriptDebug.Log( "The generated code is not compatible with your current uScript Runtime " + uScript_MasterComponent.Version, uScriptDebug.Type.Error );
       ExposedVariables = null;
       UnityEngine.Debug.Break();
    }
 }
示例#3
0
 protected override bool FireControlActivated(HandControls hc)
 {
     return(hc.TriggerPulled.Any);
 }
示例#4
0
 private void Start()
 {
     rb              = GetComponent <Rigidbody>();
     playerObj       = FindPlayerObj();
     otherHandScript = otherHand.GetComponent <HandControls>();
 }
示例#5
0
 protected abstract bool FireControlActivated(HandControls hc);
示例#6
0
    protected override void HandAttachedUpdate(Hand hand)
    {
        base.HandAttachedUpdate(hand);

        HandControls hc = ControlsManager.Instance.GetControlsFromHand(hand);

        //Update other components when held
        foreach (IHeldUpdateable hu in heldUpdateables)
        {
            hu.HeldUpdate();
        }

        //Raycasting comes last as returning form the function is an option

        RaycastHit hitInfo;

        if (Physics.Raycast(barrel.transform.position, barrel.transform.forward, out hitInfo, Mathf.Infinity))
        {
            if (hitInfo.collider != null)
            {
                //we hit a collider
                GameCube cube = hitInfo.collider.GetComponent <GameCube> ();

                if (cube != null)
                {
                    //When we look at a different cube or the cube we look at changes
                    if (updateUI == true || lastPointedAt != cube || lastPointedAtOccupying != cube.Occupying)
                    {
                        brProgressBar.ActOnCubeTimer = 0f;

                        if (lastPointedAt != null)
                        {
                            lastPointedAt.OnPointedAway();
                        }

                        if (currentID >= 0)
                        {
                            canUpdate = cube.OnPointedAt(buildables [currentID].GetComponent <IPlaceable> (), this);
                        }
                        else
                        {
                            canUpdate = cube.OnPointedAt(null, this);
                        }
                        updateUI = false;
                    }

                    //Called every frame that we point to the cube
                    lastPointedAt          = cube;
                    lastPointedAtOccupying = cube.Occupying;

                    if (hc.TriggerPulled.Any && built == false)
                    {
                        if (brProgressBar.ActOnCubeTimer <= 0)
                        {
                            aSource.clip = buildChargeClip;
                        }

                        if (aSource.isPlaying == false)
                        {
                            aSource.time = Mathf.Min(aSource.clip.length, brProgressBar.ActOnCubeTimer);
                            aSource.Play();
                        }

                        brProgressBar.ActOnCubeTimer += Time.deltaTime;


                        if (brProgressBar.ActOnCubeTimer >= brProgressBar.holdToActTime)
                        {
                            ActOnCube(cube);
                            brProgressBar.ActOnCubeTimer = 0f;
                            built    = true;
                            updateUI = true;
                        }
                    }
                    else
                    {
                        brProgressBar.ActOnCubeTimer = Mathf.Max(0f, brProgressBar.ActOnCubeTimer - (Time.deltaTime * 2f));
                        aSource.Stop();
                    }

                    if (hc.TriggerPulled.Up)
                    {
                        built = false;
                    }

                    return;
                }
            }
        }

        //missed cube tihs frame, but last frame was hitting a box
        if (lastPointedAt != null)
        {
            lastPointedAt.OnPointedAway();

            lastPointedAt = null;

            brProgressBar.ActOnCubeTimer = 0f;
        }
    }