void Start () {
        gs = GameObject.Find("GameState").GetComponent<GameState>();
		gc = GameObject.Find("HandOfGod").GetComponent<GrabController>();
        tc = GameObject.Find("Tutorials").GetComponent<TutorialController>();
        ui = GameObject.Find("UI").GetComponent<UIManager>();
        sh = GameObject.Find("SoundHelper").GetComponent<SoundHelper>();
        planet = GameObject.Find("Planet");

        musicsource = gameObject.GetComponent<AudioSource>();
        StartCoroutine(startMusic());

        source = gameObject.AddComponent<AudioSource>();
        source.clip = crashSpaceship;
        source.loop = false;
        attackSource = gameObject.AddComponent<AudioSource>();
        attackSource.clip = attackSound;
        attackSource.loop = false;
        jetStartSource = gameObject.AddComponent<AudioSource>();
        jetStartSource.clip = jetstartSound;
        jetStartSource.loop = false;

        gs.ActiveSkill = 0;
        gs.CollectedResources = 0;
        bakeTimer = Time.time;
      
        // Create planet landscape
        planet.layer = 10;
        planet.GetComponent<RandomObjectScattering> ().Setup ();
        

        readyToBakePathfinding = true;
	}
 public EnemyActionController(Brain brain)
 {
     this.brain     = brain;
     enemy          = (brain.owner as Enemy);
     oldIndex       = -1;
     grabController = new GrabController();
 }
Esempio n. 3
0
    void OnTriggerExit(Collider other)
    {
        //BallSphereから手が出ていくとき
        if (other.CompareTag("Grabber"))
        {
            var grabController = other.GetComponent <GrabController>();
            grabController.inSphere = false;

            var trackedObject = other.GetComponent <SteamVR_TrackedObject>();
            var device        = SteamVR_Controller.Input((int)trackedObject.index);
            device.TriggerHapticPulse(1500);

            //Ballを取り出すとき
            if (grabController.Grabbing)
            {
                this.grabController = grabController;
                instantiatedBall.GetComponent <Rigidbody>().useGravity = true;
                instantiatedBall.GetComponent <Collider>().isTrigger   = false;
                instantiatedBall = null;
                StartCoroutine(DelayMethod(intervalTime, () =>
                {
                    InstantiateAndInitialize();
                    scaleUp.Play();
                }));
            }
        }
    }
Esempio n. 4
0
    public void OnUngrab()
    {
        controller = null;
        isGrabbed  = false;

        AfterOnUnGrab();
    }
Esempio n. 5
0
    public void OnHighlight(GrabController controller)
    {
        if (!isGrabbed)
        {
            this.controller = controller;
            isHighlighted   = true;

            if (shouldHighlight)
            {
                if (savedMaterials == null || highlightMaterials == null)
                {
                    savedMaterials     = GetComponent <Renderer>().materials;
                    highlightMaterials = new Material[savedMaterials.Length];
                    for (int i = 0; i < savedMaterials.Length; i++)
                    {
                        highlightMaterials[i] = highlightMaterial;
                    }
                }
                GetComponent <Renderer>().materials = highlightMaterials;
            }
            if (shouldUseGhost)
            {
                ghost.gameObject.SetActive(true);
                for (int i = 0; i < transform.childCount; i++)
                {
                    if (transform.GetChild(i).name != ghost.name)
                    {
                        transform.GetChild(i).gameObject.SetActive(false);
                    }
                }
            }
        }
    }
Esempio n. 6
0
 private void Start()
 {
     renderer        = GetComponent <SpriteRenderer>();
     tileMapCollider = tileMap.GetComponent <Collider2D>();
     collider        = GetComponent <Collider2D>();
     grabCtl         = GetComponent <GrabController>();
     source          = GetComponent <AudioSource>();
 }
        public override void OnGrabSuccess(VR_Controller controller)
        {
            activeController = controller;
            currentGrabState = GrabState.Grab;
            RaiseOnGrabStateChangeEvent(GrabState.Grab);

            GrabController.SetVisibility(!GetCurrentHandInteractSettings().hideHandOnGrab);
        }
Esempio n. 8
0
    public override void AfterOnGrab()
    {
        interationPoint.rotation = transform.rotation;
        interationPoint.Rotate(new Vector3(-90, 0, 0));

        controller.trackedControllerBase.RegisterTrackpadListener(this);
        savedController = controller;
    }
 private void Update()
 {
     GC = GameObject.FindGameObjectWithTag("Machine").GetComponent <GrabController>();
     if (Player != null)
     {
         GC.isup = true;
         Player.GetComponent <Transform>().position = this.gameObject.GetComponent <Transform>().position;
     }
 }
Esempio n. 10
0
    void Start()
    {
        trackedControllerBase = GetComponentInParent <TrackedControllerBase>();
        trackedControllerBase.RegisterTrackpadListener(this);

        grabController = GetComponent <GrabController>();

        head = GameObject.Find("Camera (eye)");
    }
Esempio n. 11
0
 protected virtual void Awake()
 {
     _rb       = GetComponent <Rigidbody>();
     _grabber  = GetComponent <GrabController>();
     _movement = GetComponent <MovementController>();
     _body     = GetComponent <Collider>();
     _head     = transform.Find("Head");
     _feet     = GetComponentInChildren <FootCollider>();
     _animator = GetComponent <Animator>();
 }
Esempio n. 12
0
 void OnTriggerEnter(Collider other)
 {
     if (other.CompareTag("Grabber") && grabber != other.gameObject)
     {
         grabber        = other.gameObject;
         grabController = grabber.GetComponent <GrabController>();
         var trackedObject = grabber.GetComponent <SteamVR_TrackedObject>();
         device = SteamVR_Controller.Input((int)trackedObject.index);
         device.TriggerHapticPulse(2500);
     }
 }
Esempio n. 13
0
 // Use this for initialization
 void Start()
 {
     SignBoard.SetActive(true);
     tutoText            = SignBoard.transform.GetComponentInChildren <TextMeshPro>();
     rightGrabController = GameObject.Find("RightController").GetComponent <GrabController>();
     leftGrabController  = GameObject.Find("LeftContorller").GetComponent <GrabController>();
     rightController     = GameObject.Find("RightController").GetComponent <VirtualViveController>();
     leftController      = GameObject.Find("LeftContorller").GetComponent <VirtualViveController>();
     enemy = GameObject.Find("EnemySpawner").GetComponent <EnemySpawner>();
     alpha = 1.0f;
 }
        private void ResetActiveControllerState()
        {
            activeController.UsePositionOffset = true;
            activeController.UseRotationOffset = true;

            activeController.SetPositionAndRotationControlMode(MotionControlMode.Engine, MotionControlMode.Engine);

            GrabController.SetVisibility(true);

            if (activeController != null)
            {
                ResetControllerState(activeController);
            }
        }
Esempio n. 15
0
 void OnTriggerExit(Collider other)
 {
     if (other.gameObject == grabber)
     {
         if (period <= 0f)  //Throwせずにcollisionがなくなったとき
         {
             period = Mathf.Min(rb.velocity.magnitude * periodValue + (initialPosition - transform.position).magnitude * periodValue, maxPeriodTime);
         }
         grabber        = null;
         grabController = null;
         device         = null;
         preGrab        = false;
         grabbing       = false;
     }
 }
Esempio n. 16
0
    /// <summary>
    /// initial setup of this controller
    /// </summary>
    private void InitController()
    {
        // TO REMOVE -  -   -   -   -
        Application.targetFrameRate = 140;
        QualitySettings.vSyncCount  = 0;

        // Get the reff for the physics controller
        physicsCharacter = GetComponentInChildren <PhysicsCharacterController>();
        // get the ref of the target animator
        playerTargetAnimator = GetComponentInChildren <Animator>();

        // Validate the reff
        // if fails to find the physics controller
        if (!physicsCharacter || !playerTargetAnimator)
        {
            // Close the aplication
            AplicationFuncs.CloseApp();
            return;
        }

        // Debug information and initialize  the parts
        InformationPanel.DebugConsoleInput("Physics System connected!");
        physicsCharacter.InitParts();

        // Define the maximum velocity
        physicsCharacter.SetCharacterMaxSpeed(characterMaxVelocity);
        // define the kill speed
        physicsCharacter.SetCharacterKillVelocity(this.killVelocity);

        // Stunted  -   -   -   -   -
        // regist the for the stunted event
        physicsCharacter.stuntedDelegate += StuntedCallback;
        // init vars
        stunted = false;


        // Grab controller  -   -   -   -   -
        // get ref to controller
        this.playerGrabController = this.GetComponentInChildren <GrabController>();
        // Init with enable tag
        this.playerGrabController.Init(controllerState: true, lHand: ref LeftHandGO, rHand: ref RightHandGO);

        // Regists for jump delegate
        InputManager.Instance.jumpDelegate += () => { physicsCharacter.Jump(this.JumpValue); };

        // regist the controller to the action event
        InputManager.Instance.actionDelegate += playerGrabController.ActionCallback;
    }
        protected override void DropUpdate()
        {
            GrabController.SetVisibility(true);

            rb.velocity        = Vector3.zero;
            rb.angularVelocity = Vector3.zero;

            joint.useSpring = false;

            activeController.CleanCurrentGrab();
            activeController = null;

            RaiseOnGrabStateChangeEvent(GrabState.Drop);
            currentGrabState = GrabState.UnGrab;
            RaiseOnGrabStateChangeEvent(GrabState.UnGrab);
        }
        private void SetFinalGrabState()
        {
            ChangeCollidersEnable(enableColliderOnGrab);
            SetFinalHandPositionAndRotation();

            if (grabMode == GrabMode.Joint)
            {
                SetupFixedJoint();
            }

            //should the hand be hide?
            GrabController.SetVisibility(!GetCurrentHandInteractSettings().hideHandOnGrab);

            //parent the objects so they exist on the same space
            transform.parent = activeController.transform;
        }
Esempio n. 19
0
        private async void Grab_Data_Commence(object sender, EventArgs e)
        {
            var selectors = new XmlProduct();

            if (grabDataNameLabel.Checked && !string.IsNullOrWhiteSpace(grabDataNameTextBox.Text))
            {
                selectors.Name = grabDataNameTextBox.Text;
            }

            if (grabDataFullDescriptionLabel.Checked && !string.IsNullOrWhiteSpace(grabDataFullDescriptionTextBox.Text))
            {
                selectors.Description = grabDataFullDescriptionTextBox.Text;
            }

            if (grabDataPictureLabel.Checked && !string.IsNullOrWhiteSpace(grabDataPictureTextBox.Text))
            {
                selectors.Picture = grabDataPictureTextBox.Text;
            }

            if (grabDataAttributesLabel.Checked && !string.IsNullOrWhiteSpace(grabDataAttributesTextBox.Text))
            {
                selectors.Attributes = new string[] { grabDataAttributesTextBox.Text }
            }
            ;

            if (grabDataCategoryLabel.Checked && !string.IsNullOrWhiteSpace(grabDataCategoryTextBox.Text))
            {
                selectors.Categories = new string[] { grabDataCategoryTextBox.Text }
            }
            ;

            if (grabDataDocumentsLabel.Checked && !string.IsNullOrWhiteSpace(grabDataDocumentsTextBox.Text))
            {
                selectors.Documents = new string[] { grabDataDocumentsTextBox.Text }
            }
            ;

            WriteLine(consoleTextBox, "Grabbing data");

            GrabController gc = new GrabController();

            await gc.GrabAsync(grabSiteTextBox.Text, _comparisonData.ToList(), selectors);

            _grabbedData = gc._grabbedData;

            WriteLine(consoleTextBox, "Product(s) imported successfully: " + _grabbedData.Count);
        }
Esempio n. 20
0
    public void OnGrab(GrabController controller)
    {
        this.controller = controller;
        isGrabbed       = true;

        if (interationPoint == null)
        {
            interationPoint      = new GameObject().transform;
            interationPoint.name = "InteractionPoint";
        }

        interationPoint.position = controller.transform.position;
        interationPoint.rotation = controller.transform.rotation;
        interationPoint.SetParent(transform, true);

        AfterOnGrab();
    }
    void Start () {
        gs = GameObject.Find("GameState").GetComponent<GameState>();
        gc = GameObject.Find("HandOfGod").GetComponent<GrabController>();
		ui = GameObject.Find ("UI").GetComponent<UIManager> ();

		lightning = GameObject.Find("Lightning").GetComponent<RecursiveLightning>();
		fire = GameObject.Find ("Fire");
        fire.GetComponent<ParticleSystem>().enableEmission = false;
		heal = GameObject.Find ("Heal");

        foreach (Skills s in Enum.GetValues(typeof(Skills)))
        {
            skillDisabled[s] = false;
        }

		source = GetComponent<AudioSource>();
		vol = UnityEngine.Random.Range (volLowRange, volHighRange);
    }
Esempio n. 22
0
    void Tap_Updated(GestureRecognizer gesture)
    {
        if (gesture.State == GestureRecognizerState.Began)
        {
            _ball = FingersUtilityExtensions.GetTouchedObject(gesture).GetComponent <GrabController>();
            if (_ball.CompareTag("Ball"))
            {
                _ball.GetComponent <GrabController>().Expand();
            }
        }

        if (gesture.State == GestureRecognizerState.Ended)
        {
            if (_ball == null)
            {
                return;
            }
            _ball.GetComponent <GrabController>().Shrink();
            _ball = null;
        }
    }
Esempio n. 23
0
    public void OnUnhighlight(GrabController controller)
    {
        if (controller == this.controller)
        {
            this.controller = null;
            isHighlighted   = false;

            if (shouldHighlight)
            {
                GetComponent <Renderer>().materials = savedMaterials;
            }
            if (shouldUseGhost)
            {
                ghost.gameObject.SetActive(false);
                for (int i = 0; i < transform.childCount; i++)
                {
                    if (transform.GetChild(i).name != ghost.name)
                    {
                        transform.GetChild(i).gameObject.SetActive(true);
                    }
                }
            }
        }
    }
Esempio n. 24
0
 // Use this for initialization
 void Start()
 {
     _instance = this;
 }
Esempio n. 25
0
 public override void AfterOnUnGrab()
 {
     savedController.trackedControllerBase.UnregisterTrackpadListener(this);
     savedController = null;
 }
        /// <summary>
        /// Called by VR_Input, to let know what we are grabbing this object
        /// </summary>
        /// <param name="controller"></param>
        public virtual void OnGrabSuccess(VR_Controller controller)
        {
            if (preventDefault)
            {
                activeController = controller;
                CurrentGrabState = GrabState.Grab;
                RaiseOnGrabStateChangeEvent(CurrentGrabState);
                return;
            }

            previusKinematicValue = rb.isKinematic;

            //stop this object to be interactable
            CanInteract = false;

            //set the active controller
            activeController = controller;


            if (rb != null && grabMode == GrabMode.Joint)
            {
                rb.isKinematic          = true;
                originalInterpolateMode = rb.interpolation;
                rb.interpolation        = RigidbodyInterpolation.None;
            }

            if (grabMode == GrabMode.Physics)
            {
                physicsUpdateState      = PhysicsUpdateState.NoCollision;
                previusUseGravityState  = rb.useGravity;
                previusGravityState     = rb.useGravity;
                rb.useGravity           = false;
                rb.isKinematic          = false;
                rb.useGravity           = false;
                rb.interpolation        = RigidbodyInterpolation.Interpolate;
                originalInterpolateMode = rb.interpolation;
                OverridePhysicsMaterial(zeroFrictionOrBouncinessMaterial);

                activeController.UseRotationOffset = false;
                activeController.UsePositionOffset = false;
            }



            //disable collision with the grabbable and the hand
            if (activeController.Collider != null)
            {
                IgnoreCollision(activeController.Collider);
            }


            //if this object shoudl fly to hand disable colliders while flying otherwise set desire collider state
            if (shouldFly)
            {
                //disable colliders while flying
                ChangeCollidersEnable(false);
            }
            else
            {
                ChangeCollidersEnable(enableColliderOnGrab);
            }

            //if we are using a perfect grab
            if (perfectGrab)
            {
                //parent the objects so they exist on the same space
                transform.parent = activeController.transform;
                GrabController.SetVisibility(!GetCurrentHandInteractSettings().hideHandOnGrab);
                SetupFixedJoint();

                //set the current grab state
                CurrentGrabState = GrabState.Grab;
                //raise grab state change event
                RaiseOnGrabStateChangeEvent(CurrentGrabState);
                return;
            }
            else
            {
                //set fly values
                if (shouldFly)
                {
                    grabStartTime     = Time.time;
                    grabStartPosition = transform.position;
                    grabStartRotation = transform.rotation;
                }

                else
                {
                    SetFinalGrabState();
                }

                CurrentGrabState = shouldFly ? GrabState.Flying : GrabState.Grab;
            }


            //raise the event
            RaiseOnGrabStateChangeEvent((shouldFly ? GrabState.Flying : GrabState.Grab));
        }
Esempio n. 27
0
 // Use this for initialization
 void Start()
 {
     myGrabController = GameObject.Find("GameManager").GetComponent <GrabController>();
 }
Esempio n. 28
0
 void Start()
 {
     Debug.Log("WorldAnchorStore.GetAsync()");
     WorldAnchorStore.GetAsync(AnchorStoreReady);
     _grabController = GetComponent <GrabController>();
 }
    void Update()
    {
        updateVirtualWorldBoxCenter();

        ProcessAllTriggers();
       

        //Start Event
        if (!_actionTriggered && SupportedTriggers[0].Success)
        {
            _actionTriggered = true;
        }

        //Stop Event
        if (_actionTriggered && SupportedTriggers[2].Success)
        {
            _actionTriggered = false;
        }

        if (!_actionTriggered)
        {
            return;
        }

        TrackTrigger trgr = (TrackTrigger)SupportedTriggers[1];

        if (trgr.Success)
        {

            // Translation:
            {
                Vector3 vec = trgr.Position;

                // Be sure we have valid values:
                if (VirtualWorldBoxDimensions.x <= 0)
                {
                    VirtualWorldBoxDimensions.x = 1;
                }

                if (VirtualWorldBoxDimensions.y <= 0)
                {
                    VirtualWorldBoxDimensions.y = 1;
                }

                if (VirtualWorldBoxDimensions.z <= 0)
                {
                    VirtualWorldBoxDimensions.z = 1;
                }

                // Get the relative position in the virtual box:
                float left = VirtualWorldBoxCenter.x - (VirtualWorldBoxDimensions.x) / 2;
                float top = VirtualWorldBoxCenter.y - (VirtualWorldBoxDimensions.y) / 2;
                float back = VirtualWorldBoxCenter.z - (VirtualWorldBoxDimensions.z) / 2;

                vec.x = (vec.x * VirtualWorldBoxDimensions.x);
                vec.y = (vec.y * VirtualWorldBoxDimensions.y);
                vec.z = (vec.z * VirtualWorldBoxDimensions.z);


                //invert
                if (InvertTransform.Position.X)
                {
                    vec.x = left + VirtualWorldBoxDimensions.x - vec.x;
                }
                else
                {
                    vec.x += left;
                }

                if (InvertTransform.Position.Y)
                {
                    vec.y = top + VirtualWorldBoxDimensions.y - vec.y;
                }
                else
                {
                    vec.y += top;
                }

                if (InvertTransform.Position.Z)
                {
                    vec.z = back + VirtualWorldBoxDimensions.z - vec.z;
                }
                else
                {
                    vec.z += back;
                }

                // Use the flags to indicate which axis are active
                if (Constraints.Position.X)
                {
                    vec.x = this.gameObject.transform.localPosition.x;
                }

                if (Constraints.Position.Y)
                {
                    vec.y = this.gameObject.transform.localPosition.y;
                }

                if (Constraints.Position.Z)
                {
                    vec.z = this.gameObject.transform.localPosition.z;
                }

                float planetradius = planet.GetComponent<MeshFilter>().mesh.bounds.size.x * 0.5f * planet.transform.localScale.x;
                float distance = Vector3.Distance(planet.transform.position, transform.position);        

                Vector3 currentVec = this.gameObject.transform.position;
                Vector3 handpos_local = this.gameObject.transform.localPosition;

                if (distance > planetradius+3)
                {
    
                    // smoothing:
                    if (SmoothingFactor > 0)
                    {
                        vec = _translationSmoothingUtility.ProcessSmoothing(SmoothingType, SmoothingFactor, vec);
                    }

					if(distance > (planetradius + 13)){
                    	this.gameObject.transform.localPosition = new Vector3(vec.x, vec.y, 130.0f);
					}else{
						this.gameObject.transform.localPosition = new Vector3(vec.x, vec.y, 130.0f + (distance - (planetradius + 13)));
					}
                    lastVecX = vec.x;
                    lastVecY = vec.y;
                    lastVecZ = vec.z;

                }
                else
                {
                    this.gameObject.transform.localPosition = new Vector3(lastVecX, lastVecY, lastVecZ);    
                }

                //move projection:
                grab = GameObject.Find("HandOfGod").GetComponent<GrabController>();
                grab.moveVis(gameObject);
            }
        }
    }
Esempio n. 30
0
 private void Awake()
 {
     cachedGrabController        = GetComponent <GrabController>();
     cachedRackSocketHighlighter = GetComponent <RackSocketHighlighter>();
 }
Esempio n. 31
0
 private void Start()
 {
     grabController = FindObjectOfType <GrabController>();
 }
Esempio n. 32
0
 private void Awake()
 {
     cachedGrabController = GetComponent <GrabController>();
     cachedTransform      = GetComponent <Transform>();
     cachedAgent          = GetComponent <NavMeshAgent>();
 }
Esempio n. 33
0
 void Start ()
 {
     grabController = this.GetComponent<GrabController>();
 }
Esempio n. 34
0
            static void Prefix()
            {
                GameSession gs = Main.Instance.CurrentGameSession;

                if (gs != null && CurrentGameState == GameState.Gameplay)
                {
                    Player              player          = LynxPlayerController.Instance.Player;
                    Rigidbody           body            = LynxPlayerController.Instance.PlayerRigidbody;
                    EquipmentController equipController = GameObject.Find("EquipmentController").GetComponent <EquipmentController>();
                    RewardData          reward;
                    if (rewardsQueue.TryDequeue(out reward))
                    {
                        switch (reward.action)
                        {
                        case "push":
                            float forceMin;
                            float.TryParse(reward.args[0], out forceMin);
                            float forceMax;
                            float.TryParse(reward.args[1], out forceMax);

                            body.AddForce(UnityEngine.Random.onUnitSphere * (UnityEngine.Random.Range(forceMin, forceMax)));
                            break;

                        case "roll":
                            float rollMin;
                            float.TryParse(reward.args[0], out rollMin);
                            float rollMax;
                            float.TryParse(reward.args[1], out rollMax);

                            barrelRollAmount  = (float)random.NextDouble() * (rollMax - rollMin) + rollMax;
                            barrelRollAmount *= NextBoolean() ? 1 : -1;
                            break;

                        case "release":
                            GrabController grab = Traverse.Create(equipController).Field("m_GrabController").GetValue() as GrabController;

                            Traverse.Create(grab).Method("ReleaseGrab", grab.LeftHand).GetValue();
                            break;

                        case "equip_toggle":
                            Equipment toEquip = Equipment.CuttingTool;
                            if (equipController.CurrentEquipment == Equipment.CuttingTool)
                            {
                                toEquip = Equipment.GrappleHook;
                            }

                            Traverse.Create(equipController).Method("UnequipEquipment", equipController.CurrentEquipment).GetValue();
                            Traverse.Create(equipController).Property("CurrentEquipment").SetValue(toEquip);
                            break;

                        case "test":
                            /*ExplosionSettings es = new ExplosionSettings();
                             * es.Radius = 75;
                             * es.DamageAffectsPlayer = false;
                             * es.ForceAffectsPlayer = true;
                             * es.Force = 5000;
                             * ExplosionHelper.DoExplosionAtPosition(player.transform.position + new Vector3(0, 50, 0), es);*/
                            break;
                        }
                    }

                    if (barrelRollAmount > 0.1 || barrelRollAmount < -0.1)
                    {
                        if (barrelRollAmount > 0)
                        {
                            barrelRollAmount -= 0.01f;
                        }
                        else
                        {
                            barrelRollAmount += 0.01f;
                        }

                        player.transform.RotateAround(player.transform.position, player.transform.forward, barrelRollAmount);
                    }
                }
            }
Esempio n. 35
0
	// Use this for initialization
	void Start () {
		handler = GameObject.FindGameObjectWithTag ("UI").GetComponent<ObjectiveHandler> ();
		grab = GameObject.FindGameObjectWithTag ("Player").GetComponentInChildren<GrabController> ();
	}