Inheritance: MonoBehaviour
Example #1
0
    void OnRobotConnected(RobotInfo ifo, RobotConnector.TargetPorts ports)
    {
        HandController c = GameObject.FindObjectOfType <HandController> ();

        if (c == null || !c.IsConnected())
        {
            return;
        }
        _streamer     = new GstNetworkImageStreamer();
        _imageGrabber = new GstUnityImageGrabber();
        _imageGrabber.SetTexture2D(HandRenderer.LeapRetrival [0].MainTextureData, HandRenderer.LeapRetrival [0].Width, HandRenderer.LeapRetrival [0].Height, TextureFormat.Alpha8);
        _imageGrabber.Update();        //update once

        _handsPort = Settings.Instance.GetPortValue("HandsPort", 0);

        _streamer.SetBitRate(300);
        _streamer.SetResolution(640, 240, 30);
        _streamer.SetGrabber(_imageGrabber);
        _streamer.SetIP(ports.RobotIP, _handsPort, false);
        RobotConnector.Connector.SendData(TxKitHands.ServiceName, "HandPorts", _handsPort.ToString(), false);

        _streamer.CreateStream();
        _streamer.Stream();
        _isConnected = true;
    }
Example #2
0
    /*SteamVR_Controller.Device device;
    SteamVR_TrackedObject trackedObj;

    public SteamVR_TrackedObject.EIndex index = SteamVR_TrackedObject.EIndex.None;*/
    void Start()
    {
        boltFireSound = GetComponent<AudioSource>();
        //trackedObj = GetComponent<SteamVR_TrackedObject>();
        //device = SteamVR_Controller.Input((int)trackedObj.index);
        hc = GetComponent<HandController>();
    }
    // =========================================================================
    // PUBLIC METHODS
    // =========================================================================

    // Start is called before the first frame update
    void Start()
    {
        Debug.Log("serial interaction start up");
        // Set up the hand controller
        handController = Hand.GetComponent <HandController>();

        // skip if not enabled
        if (!enableOutput)
        {
            return;
        }

        textOutput = false;
        if (!textOutput)
        {
            Debug.Log("Serial inteaction entered stream try");
            // Set the read/write timeouts
            stream.ReadTimeout  = 500;
            stream.WriteTimeout = 500;

            // open stream
            try
            {
                stream.Open();
                Debug.Log("stream opened");
            }
            catch
            {
                throw new System.Exception("Out Stream is not available!");
                //Debug.Log("serial interaction stream not available");
            }
            Debug.Log("serial interaction past try catch");
        }
        Debug.Log("serial interaction start up complete");
    }
Example #4
0
    public static HandModel GetHandModel(HandController controller, HandModelType type)
    {
        HandModel[] allHands;

        switch (type)
        {
            case HandModelType.Graphic:
                allHands = controller.GetAllGraphicsHands();
                break;

            case HandModelType.Physics:
                allHands = controller.GetAllPhysicsHands();
                break;

            default:
                allHands = controller.GetAllGraphicsHands();
                break;
        }

        if (allHands.Length == 0)
        {
            return null;
        }

        return allHands[0];
    }
Example #5
0
    public void drop()
    {
        beingHeld  = false;
        curHolding = null;

        deleteTimer = DeleteTime;
    }
Example #6
0
 private static void StartNextTurn(bool nextPlayer = true)
 {
     if (nextPlayer)
     {
         Game.Current.CurrentPlayerIndex++;
         if (Game.Current.CurrentPlayerIndex >= Game.Current.Players.Count)
         {
             Game.Current.CurrentPlayerIndex = 0;
         }
     }
     SidebarController.ToggleUserButtons(Game.Current.CurrentPlayer.IsAI == false);
     SidebarController.RenderTurnPlayerLabel();
     SidebarController.RenderTurnPointsLabel(0);
     SidebarController.RenderScoreboard();
     HandController.LoadHand(Game.Current.CurrentPlayer);
     if (Game.Current.CurrentPlayer.IsAI)
     {
         Game.Current.CurrentPlayer.AI.PlayTurn();
     }
     else
     {
         if (nextPlayer)
         {
             Game.Save(autosave: true);
         }
     }
 }
 public override void ButtonUsed(HandController hand, ButtonEventKind buttonEventKind)
 {
     if (buttonEventKind == ButtonEventKind.TriggerButtonDown)
     {
         Trigger(hand);
     }
 }
Example #8
0
 public void SetController(HandController controller) {
   controller_ = controller;
   for (int i = 0; i < fingers.Length; ++i) {
     if (fingers[i] != null)
       fingers[i].SetController(controller_);
   }
 }
    IEnumerator Deal()
    {
        GameDeck.Initialize();
        HandController Player1 = Hand1.GetComponent <HandController>();

        Player1.Initialize(GameDeck, HandType.Player);
        Player1.gameObject.AddComponent <PlayerBrain>().Initialize(CombatZone);
        yield return(StartCoroutine(Player1.Deal()));

        HandController Player2 = Hand2.GetComponent <HandController>();

        Player2.Initialize(GameDeck, HandType.Opponent);
        Player2.gameObject.AddComponent <PlayerBrain>().Initialize(CombatZone);
        yield return(StartCoroutine(Player2.Deal()));

        Players.Add(Player1);
        Players.Add(Player2);
        //GameCard trumpCard = GameObjectUtils.AddAndPosition (CardPrefab, this.gameObject, new Vector3()).GetComponent<GameCard> ();
        //Debug.Log (null != GameDeck);
        //trumpCard.Initialize (GameDeck.TakeCardFromDeck ());

        yield return(new WaitForSeconds(1));

        BeginGame();
    }
 public override void Init(Mover mover, HandController handcontroller, GameObject sight)
 {
     base.Init(mover, handcontroller, sight);
     medKitSensor = sight.GetComponent <PickableMedKitSensor>();
     weaponSensor = sight.GetComponent <PickableWeaponSensor>();
     health       = mover.GetComponent <Health>();
 }
Example #11
0
 public void Grab(HandController handController)
 {
     foreach (IButtonTarget target in targets)
     {
         target.ButtonPressed();
     }
 }
        protected override void DoEngaging()
        {
            if (campedMedKit != null)
            {
                Mover.MoveTowardsPosition(campedMedKit.transform.root.position);

                if (CurrentEnemyTarget != null)
                {
                    Mover.RotateTowardsDirection(GetPredictiveAimDirection(CurrentEnemyTarget));
                    HandController.Use();
                }
                else
                {
                    Mover.RotateTowardsPosition(campedMedKit.transform.root.position);
                }
            }
            else if (CurrentUziTarget != null)
            {
                Mover.MoveTowardsPosition(CurrentUziTarget.transform.root.position);
                Mover.RotateTowardsPosition(CurrentUziTarget.transform.root.position);
            }
            else if (CurrentEnemyTarget != null)
            {
                Mover.MoveRightAroundPosition(CurrentEnemyTarget.transform.root.position);
                Mover.RotateTowardsDirection(GetPredictiveAimDirection(CurrentEnemyTarget));
                HandController.Use();
            }
        }
 // Use this for initialization
 void Start()
 {
     camera     = GameObject.FindGameObjectWithTag("MainCamera");
     controller = GameObject.FindGameObjectWithTag("GameController").GetComponent <HandController> ();
     palmPos    = new Vector3(0f, 0f, 0f);
     rotation   = new Vector3(0f, -2f, 0f);
 }
    public override void OnInspectorGUI()
    {
        HandController t = target as HandController;

        if (t.Gears.Count == 0)
        {
            t.createGears();
        }

        EditorGUILayout.LabelField("Gears:");
        {
            EditorGUI.indentLevel++;
            foreach (var entry in t.Gears)
            {
                entry.Value.angle = EditorGUILayout.FloatField(entry.Key.ToString().ToLower(), entry.Value.angle);
            }
            EditorGUI.indentLevel--;
        }

        EditorGUILayout.Space();

        if (GUILayout.Button("Generate Skeleton"))
        {
            Transform parent = t.transform;

            for (HandBoneIndex i = HandBoneIndices.WristStart; i < HandBoneIndices.WristEnd; ++i)
            {
                parent = createBoneNode(parent, i);
            }

            Transform thumb = parent, index = parent, middle = parent, ring = parent, pinky = parent;

            for (HandBoneIndex i = HandBoneIndices.ThumbStart; i < HandBoneIndices.ThumbEnd; ++i)
            {
                thumb = createBoneNode(thumb, i);
            }
            for (HandBoneIndex i = HandBoneIndices.IndexStart; i < HandBoneIndices.IndexEnd; ++i)
            {
                index = createBoneNode(index, i);
            }
            for (HandBoneIndex i = HandBoneIndices.MiddleStart; i < HandBoneIndices.MiddleEnd; ++i)
            {
                middle = createBoneNode(middle, i);
            }
            for (HandBoneIndex i = HandBoneIndices.RingStart; i < HandBoneIndices.RingEnd; ++i)
            {
                ring = createBoneNode(ring, i);
            }
            for (HandBoneIndex i = HandBoneIndices.PinkyStart; i < HandBoneIndices.PinkyEnd; ++i)
            {
                pinky = createBoneNode(pinky, i);
            }

            HandRig rig = t.GetComponent <HandRig>();
            if (rig)
            {
                rig.searchNodes();
            }
        }
    }
Example #15
0
    /// <summary>
    /// Add new glove geometry to the world.
    /// </summary>
    /// <param name="ID">The ID of the glove to add.</param>
    public void AddGlove(int ID)
    {
        //create a new hand object with the ID
        GameObject newGlove = new GameObject();

        newGlove.name = "Glove " + ID.ToString();
        HandController gloveScript = (HandController)newGlove.AddComponent(typeof(HandController));

        //set joint angle ranges in library
        IntPtr minPtr = Marshal.AllocHGlobal(Marshal.SizeOf(gloveScript.rotationMinimum[0]) * 15);

        Marshal.Copy(gloveScript.rotationMinimum.ToArray(), 0, minPtr, 15);
        IntPtr maxPtr = Marshal.AllocHGlobal(Marshal.SizeOf(gloveScript.rotationMaximum[0]) * 15);

        Marshal.Copy(gloveScript.rotationMaximum.ToArray(), 0, maxPtr, 15);
        setAngles(ID, minPtr, maxPtr);
        Marshal.FreeHGlobal(minPtr);
        Marshal.FreeHGlobal(maxPtr);

        gloveScript.ID = ID;
        gloves.Add(ID, gloveScript);

        //add pairing block
        pairInterface.AddPairBlock(ID);

        //highlight new glove
        Camera.main.GetComponent <HighlightEffect>().highlightObject = newGlove;

        //update the orbit center
        UpdateOrbit();
    }
 private void Start()
 {
     if (hand == null)
     {
         hand = GameObject.Find("hand").GetComponent <HandController>();
     }
 }
Example #17
0
    void Update()
    {
        HandModel[]    models = null;
        HandController hand   = (HandController)controllerObject.GetComponent <HandController>();

        models = hand.GetAllGraphicsHands();

        if (models.Length == 1)
        {
            Vector3 handRotation = (models[0].GetPalmRotation().ToEulerAngles() * Rad2Deg);
            //Debug.Log(handRotation.z);
            if (handRotation.x > 30 && handRotation.x < 330)
            {
                handRotation.x = (tiltMaze.transform.rotation.ToEulerAngles() * Rad2Deg).x;
            }
            if (handRotation.z > 30 && handRotation.z < 330)
            {
                handRotation.z = (tiltMaze.transform.rotation.ToEulerAngles() * Rad2Deg).z;
            }
            tiltMaze.transform.rotation = Quaternion.Euler(new Vector3(handRotation.x, 0f, handRotation.z));

            //Debug.Log(tiltMaze.transform.rotation.ToEulerAngles() * Rad2Deg);
            FingerModel[] fingers = models[0].fingers;
            for (int x = 0; x < fingers.Length; x++)
            {
                Debug.DrawRay(fingers[x].GetRay().origin, fingers[x].GetRay().direction, Color.green);
            }
        }
    }
Example #18
0
    //将Leap Motion中获取到的坐标信息转化为Unity的世界坐标
    public static Vector3 leapVectorToUnityVector3(HandController hc, Leap.Vector leapVector)
    {
        Vector3 unityPosition_now = leapVector.ToUnityScaled(false);
        Vector3 worldPosition_now = hc.transform.TransformPoint(unityPosition_now);

        return(worldPosition_now);
    }
Example #19
0
    void OnTriggerEnter(Collider other)
    {
        if (other.tag == tag)
        {
            Part part = other.GetComponentInParent <Part>();
            if (part == null || part.separated)
            {
                return;
            }

            HandController grabbedHand = part.grabbedBy;
            if (grabbedHand == null || grabbedHand.state != HandController.State.Deconstructing)
            {
                return;
            }

            Part newPart = Instantiate(part);
            newPart.transform.position        = part.transform.position;
            newPart.transform.rotation        = part.transform.rotation;
            newPart.separated                 = true;
            newPart.originJoint.connectedBody = null;

            Rigidbody rigidbody = newPart.GetComponent <Rigidbody>();
            rigidbody.useGravity = true;

            grabbedHand.Attach(newPart);
            part.gameObject.SetActive(false);
        }
    }
    void Start()
    {
        HandController controller = GetComponent <HandController>();

        controller.enabled = false;
        controller.PauseRecording();
    }
        protected override void DoEngaging()
        {
            engagingMovementRoutine.UpdateMovementRoutine(CurrentEnemyTarget.transform.root.position);
            Mover.RotateTowardsDirection(GetPredictiveAimDirection(CurrentEnemyTarget));

            HandController.Use();
        }
Example #22
0
        protected Hero(HeroInfo heroInfo)
        {
            maxHp     = heroInfo.Hp;
            currentHp = maxHp;

            if (HpChangedEvent != null)
            {
                HpChangedEvent(this, currentHp, maxHp);
            }

            maxAmmo     = heroInfo.Ammo;
            currentAmmo = maxAmmo;

            if (AmmoChangedEvent != null)
            {
                AmmoChangedEvent(this, currentAmmo, maxAmmo);
            }

            bullets = new BulletInfo[maxAmmo];

            bulletSprite = heroInfo.BulletSprite;
            bulletSpeed  = heroInfo.BulletSpeed;

            animator = heroInfo.Animator;

            hand = new HandController(heroInfo);

            bodyParts = HitBox.GetHitBox(heroInfo.HitBox);
        }
Example #23
0
 public void ComputerDrop(HandController opponentHand, CardController card)
 {
     Neutral.cardDropped(card);
     opponentHand.RemoveCard(card.getCard());
     card.gameObject.SetActive(false);
     turn++;
 }
Example #24
0
    private void Start()
    {
        side = GetComponentInParent <SideGUI_canvas>();

        myTransform = transform;

        myTransform.DestroyAllChildren();

        for (int i = 0; i < GameConstants.NUMBER_OF_BOARD_SLOTS_PER_PLAYER; i++)
        {
            BoardSquareGUI_canvas slotGUI = Instantiate(slotPrefab, myTransform);
            slotGUI.side            = side;
            slotGUI.gameObject.name = "slot_" + i;
        }

        // Callbacks
        HandController hand = FindObjectOfType <HandController>();

        if (side.owner == Owner.PLAYER)
        {
            hand.OnPlayerPlayedCard += PlayerPlayedCard;
        }
        else if (side.owner == Owner.ENEMY)
        {
            hand.OnEnemyPlayedCard += EnemyPlayedCard;
        }
        else
        {
            Debug.LogError("Who are you?");
        }
    }
Example #25
0
    void Start()
    {
        leftArrow              = GameObject.Find("LeftArrow").GetComponent <DirrectionLightUp>();
        rightArrow             = GameObject.Find("RightArrow").GetComponent <DirrectionLightUp>();
        upArrow                = GameObject.Find("UpArrow").GetComponent <DirrectionLightUp>();
        downArrow              = GameObject.Find("DownArrow").GetComponent <DirrectionLightUp>();
        cameraStartingPosition = transform.position;
        cameraStartingRotation = transform.rotation;
        delegateReference      = new LeapEventDelegate(parseFrameAndRotate);
        cameraMovementVector   = new Vector3(0, 0, 0);
        cameraRotationVector   = new Vector3(0, 0, 0);
        fingerVectors          = new Vector3[5];
        GameObject ballGameObject = GameObject.Find("Ball");

        if (ballGameObject != null)
        {
            ball           = ballGameObject.transform;
            ballsRigidbody = ball.GetComponent <Rigidbody>();
        }



        leftHandControllerTransform  = GameObject.FindGameObjectWithTag("LeftHand").transform;
        rightHandControllerTransform = GameObject.FindGameObjectWithTag("RightHand").transform;
        leftHandController           = leftHandControllerTransform.gameObject.GetComponent <HandController>();
        rightHandController          = rightHandControllerTransform.gameObject.GetComponent <HandController>();

        leftHandControllerStartingPosition  = leftHandControllerTransform.position;
        leftHandControllerStartingRotation  = leftHandControllerTransform.rotation;
        rightHandControllerStartingPosition = rightHandControllerTransform.position;
        rightHandControllerStartingRotation = rightHandControllerTransform.rotation;
        BallsSpeed = 150f;
        offset     = 0;
    }
        protected override void DoAttacking()
        {
            Mover.MoveRightAroundPosition(CurrentEnemyTarget.transform.root.position);
            Mover.RotateTowardsDirection(GetPredictiveAimDirection(CurrentEnemyTarget));

            HandController.Use();
        }
 private void Awake()
 {
     manaCrystalBlock = transform.Find("ManaCrystalBlock").GetComponent <ManaCrystalBlock>();
     deckBlock        = transform.Find("DeckBlock").GetComponent <DeckBlock>();
     nicknameText     = transform.Find("NicknameText").GetComponent <Text>();
     hand             = transform.Find("Hand").GetComponent <HandController>();
 }
    void Start()
    {
        if (!MyNetworkLobbyManager.s_singleton.IsTutorial)
        {
            if (!isLocalPlayer) return;
        }

        hand_manager_ = GameObject.Find("HandManager");
        hand_controller_ = FindObjectOfType<HandController>();

        magic_action_list_.Add(
            0,
            FindObjectOfType<Ike3KudamonKinesisu>().KudamonKinesis);

        magic_action_list_.Add(
            1,
            GetComponent<EggPlantAttacker>().StartEggPlantPanic);

        magic_action_list_.Add(
            2,
            FindObjectOfType<SmallFruit>().SmallFruitStart);

        magic_action_list_.Add(
            3,
            FindObjectOfType<Ike3TyphoonSetting>().TyphoonOn);

        magic_action_list_.Add(
            4,
            FindObjectOfType<PeachChange>().PeachChangeStart);

        player_magic_manager_ = GetComponent<PlayerMagicManager>();
    }
Example #29
0
    //手札がタッチアップされた瞬間
    public void OnPointerUp()
    {
        // カードと重なってるならCardGeneratorで合成発動
        if (handCard_a != null && handCard_b != null)
        {
            HandController comCard = _cardGenerator.Combination(handCard_a.word_data.id, handCard_b.word_data.id);

/*          多分、startPosは途中で値変わるとまずいから、private据え置きがいいんだけど、やり方がわからん。
 *                      Vector3 _startPos{
 *                              get{
 *                                      return handCard_a.startPos;
 *                              }
 */

            comCard.transform.position = handCard_a.startPos;


            // ここから下の処理は、例えばFieldDirectorにさせるのかもなぁ。
        }
        else if (deck)
        {
        }
        else if (field)
        {
        }
        else if (obj)
        {
        }
    }
Example #30
0
 protected override void Start()
 {
     base.Start();
     _tRoot = transform.root;
     rby    = GetComponentInParent <Rigidbody>();
     holder = null;
 }
Example #31
0
    /// <summary>
    /// Initialize this instance.
    /// </summary>
    public void Initialize()
    {
        // 最初のHandCard配置
        for (int i = 0; i < 5; i++)
        {
            //int a = Random.Range (0, list.Count);
            // データ完成後はこちら。今は歯抜けなので↓
            HandController firstDraw = _deckController.GetHandFromDeck();
            // ↓実は、.で上流に遡れる! そして、また降りてこれる! これもOK → firstDraw.gameObject.transform.gameObject.GetComponent<RectTransform> ();
            RectTransform rect = firstDraw.gameObject.GetComponent <RectTransform> ();
            rect.anchoredPosition = new Vector2(handPos_x + 100 * i, handPos_y);

            /*
             * ↓の書き方では、だめ。
             * Vector2 rect = firstDraw.gameObject.GetComponent<RectTransform> ().anchoredPosition;
             * rect = new Vector2 (handPos_x+100*i, handPos_y);
             * どうやらここまでやると、Vector2の値だけ、魚拓みたいにとるらしい。途中の流れは保存されない。
             *
             * これも、だめ。
             * firstDraw.transform.position = new Vector2 (handPos_x+100*i, handPos_y);
             */
            i = firstDraw.number;
            handList.Add(firstDraw);
        }
    }
Example #32
0
    void Start()
    {
        minSwipeDistance = Screen.height * 20 / 100;
        cam = Camera.main;

        handController = GameObject.Find("Hand").GetComponent <HandController>();
    }
Example #33
0
 /** Sets the parent HandController object. */
 public void SetController(HandController controller) {
   controller_ = controller;
   for (int i = 0; i < fingers.Length; ++i) {
     if (fingers[i] != null)
       fingers[i].SetController(controller_);
   }
 }
Example #34
0
    /**  Dan's Original Method   **/

    // Grab Pan
    void GrabPan(Frame frame, HandController noob)
    {
        if (prevHandCenter == null)
        {
            prevHandCenter = noob.transform.TransformPoint(frame.Hands[0].Fingers[1].TipPosition.ToUnityScaled(false));
            HandCenter     = prevHandCenter;
        }
        else
        {
            prevHandCenter = HandCenter;
            HandCenter     = noob.transform.TransformPoint(frame.Hands[0].Fingers[1].TipPosition.ToUnityScaled(false));
        }

        // z modification of sensitivity
        z_factor = 1.0f - Mathf.Min(1.0f, HandCenter.z);


        if (frame.Hands[0].GrabStrength == 1)
        {
            float   diff = Vector3.Distance(HandCenter, prevHandCenter);
            Vector3 dir  = Vector3.Normalize(HandCenter - prevHandCenter);

            GetComponent <Transform>().position += new Vector3((dir.x * diff) * (7 * z_factor), (dir.y * diff) * (7 * z_factor), 0f);
        }
    }
 public void Start()
 {
     _controller = GetComponent<PlayerController>();
     _handController = GetComponent<HandController>();
     Globals.Initialize();
     if (!_controller)
         Debug.LogError("Player Controller Component not found!");
 }
Example #36
0
    void Start()
    {
        currentColor = targetColor;
        blockMaterial = renderer.material;
        controller = GameObject.FindGameObjectWithTag("LeapmotionController").GetComponent<HandController>();

        //audio = GetComponents<AudioSource>() [1];
    }
//	private GameObject leftPalmObject;
//	private GameObject rightPalmObject;

	// Use this for initialization
	protected void Start () {

		handController = GetComponent<HandController> ();
		spellControl = GetComponent<MageSpellControl> ();
//		leftPalmObject = new GameObject ();
//		rightPalmObject = new GameObject ();

	}
    public void Start()
    {
        _controller = GetComponent<HandController>();
        if (_controller == null)
        {
            throw new System.Exception("Cannot find Controller!");
        }

        GetHand();
    }
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        public void Awake()
        {
            if ( CursorDataProvider == null ) {
                CursorDataProvider = FindObjectOfType<HoverCursorDataProvider>();
            }

            if ( LeapControl == null ) {
                LeapControl = FindObjectOfType<HandController>();
            }
        }
Example #40
0
    public void GeneralStart()
    {
        handController = new HandController ();
        moveController = new MoveController ();
        leftCardPosition = new Vector3(transform.position.x - 0.5f,transform.position.y  - 0.5f,transform.position.z);
        rightCardPosition = new Vector3(transform.position.x + 0.5f,transform.position.y  - 0.5f,transform.position.z);

        var timeCard = (GameObject)Instantiate (Card, leftCardPosition, Quaternion.identity);
        leftCard = timeCard.GetComponent<CardBasicScript> ();
        timeCard = (GameObject)Instantiate (Card, rightCardPosition, Quaternion.identity);
        rightCard = timeCard.GetComponent<CardBasicScript> ();
    }
Example #41
0
    //GameObject hand_controller )
    public static void init()
    {
        GameObject root = GameObject.Find("Root");
        hand_controller = root.GetComponentsInChildren<HandController>()[0];
        //Mouse.root = root;

        //TODO: this check is maybe not robust to parallel calls?
        if (has_been_initialized)
            return;

        has_been_initialized = true;
        OnUpdate.register(delegate() { LeapMotion.update(); });
    }
	void Start ()
	{
		audioPlayer = GameObject.Find ("SoundObject").GetComponent<AudioPlayScript> (); 
		controller = GameObject.Find ("HeadMountedHandController").GetComponent<HandController> ();
		leftHandModel = GameObject.Find ("SecondPlayerLeft");
		rightHandModel = GameObject.Find ("SecondPlayerRight");
		result = GameObject.Find ("ResultText").GetComponent<Text> ();
		poseManager = new PoseManager ();
		if (PhotonNetwork.playerList [0].name == PhotonNetwork.playerName) {
			firstPlayer = true;
			Debug.Log ("first player");
		}
		
	}
		////////////////////////////////////////////////////////////////////////////////////////////////
		/*--------------------------------------------------------------------------------------------*/
		public virtual void Awake() {
			vHandControl = gameObject.GetComponent<HandController>();

			if ( vHandControl == null ) {
				throw new Exception("The HovercastLeapInputProvider component must be added to the "+
					"same GameObject that contains the Leap Motion HandController component.");
			}

			vSettings = new LeapInputSettings();
			UpdateSettings();

			vSideL = new LeapInputSide(true, vSettings);
			vSideR = new LeapInputSide(false, vSettings);
		}
Example #44
0
 void OnTriggerEnter(Collider collider)
 {
     if (IsFinger(collider) && gm.getColorChoserActive() && QuizManager.getHasColor())
     {
         fingerModel = collider.gameObject.GetComponentInParent<FingerModel>();
         f = fingerModel.GetLeapFinger();
         controller = fingerModel.GetController();
         shoeRender.material = QuizManager.getChosenMaterial();
         //shoeRender.material = new Material(Shader.Find(QuizManager.shaderName));
         QuizManager.changedObjects.Add(shoeRender);
         QuizManager.setHasColor(false);
         Destroy(Colors.drop);
     }
 }
Example #45
0
    //GameObject hand_controller )
    public static void init()
    {
        // reset whenever init is called
        GameObject root = GameObject.Find("root");
        hand_controller = root.GetComponentsInChildren<HandController>()[0];

        // but don't register multiple times with onUpdate
        //TODO: this check is maybe not robust to parallel calls?
        if (has_been_initialized)
            return;

        has_been_initialized = true;
        OnUpdate.register(delegate() { LeapMotion.update(); });
    }
    void Start()
    {
        max_hand_distance_ = 1;
        rigid_hand_ = GetComponent<RigidHand>();
        hand_controller_ = FindObjectOfType<HandController>();
        is_hand_exist_ = GetComponentInParent<IsHandExist>();

        hand_pos_ = rigid_hand_.GetPalmPosition();
        if (rigid_hand_.GetLeapHand().IsLeft)
        {
            hand_old_pos_ = left_hand_pos_zero_;
        }

        once_position_unification_ = false;
        distance_difference_ = new Vector3(0.0f, 0.0f, 0.0f);
    }
  /// <summary>
  /// Performs initialization of Leap Interaction.
  /// </summary>
  public void Initialize () {
    clientUnitLengthInMillimeters = MM_PER_M / transform.localScale.x;
    ReferenceObject = GetComponent<HandController>();

    m_scene = new Scene ();
    Scene.ClientUnitLengthInMillimeters = clientUnitLengthInMillimeters;
    PositionCamera();

    m_scene.RunCollisionDetection = EnableInteractionCollisions;
    m_scene.ResolveCollisions = true; //EnableInteractionCollisions;
    m_scene.AlwaysRunCollisionForHandsVsHeldObjects = true;
    
    m_scene.HandDistanceMultiplier = 1.0f;
    m_scene.DestroyClustersWhileNotHolding = true;
    
    // Don't create update the hand from the interact dll
    m_scene.UseBodyCallbacks = ShowInteractionHands;
    m_scene.UseHoldingCallbacks = true;
    
    // Start internal visualizer
    if (ShowVisualizer) { m_scene.OpenVisualDebgger (); }

    m_scene.AllowPinchWithAnyFinger = AllowPinchWithAnyFinger;
    m_scene.DisableHoldingOnPointingIndexFinger = DisableHoldingOnPointingIndexFinger;

    m_unityUtil = new UnityUtil (m_scene);
    m_unityUtil.InitLeap ();

    UnityUtil.LayerForHands = LayerForHands;
    UnityUtil.LayerForHeldObjects = LayerForHeldObjects;
    UnityUtil.LayerForReleasedObjects = LayerForReleasedObjects;

    // Optional: Initializatio of holding callbacks.
    // m_scene.OnHoldingHoverOver += OnHoldingHovers;
    // m_scene.OnHoldingStarts += OnHoldingStarts;
    m_scene.OnHoldingUpdates += DisableHandCollisions;
    m_scene.OnHoldingEnds += EnableHandCollisions;
  }
Example #48
0
 void OnEnable()
 {
     if (isMain) {
       _main = this;
     }
     _all.Add(this);
 }
Example #49
0
    void OnDisable()
    {
        if (isMain) {
          _main = null;
        }

        _all.Remove(this);

        DestroyAllHands();
    }
Example #50
0
    void OnDestroy()
    {
        if (isMain) {
          _main = null;
        }

        DestroyAllHands();
    }
Example #51
0
 /* Calling this sets this Hand Controller as the main Hand Controller.  If there was a previous main
    * Hand Controller it is demoted and is no longer the main Hand Controller.
    */
 public void SetMain()
 {
     if (_main != null) {
       _main.isMain = false;
     }
     isMain = true;
     _main = this;
 }
Example #52
0
 // Use this for initialization
 void Start()
 {
     this.gameObject.layer = 2;
     this.gameObject.tag = "Building";
     this.id = _buildingID_++;
     this.state = BuildingState.PREBUILD;
     this._collider = this.GetComponent<Collider>();
     this._collider.isTrigger = true;
     this._mouseController = GameObject.FindObjectOfType<MouseController>().GetComponent<MouseController>();
     this._handController = GameObject.FindObjectOfType<HandController>().GetComponent<HandController>();
     this._renderer = this.GetComponent<MeshRenderer>();
     this._originalColor = this._renderer.material.color;
 }
	public static bool PalmsFacingEachOther(HandController handController, HandModel leftHand, HandModel rightHand, float minAngle){

		float angle = AngleBetweenPalmsNormals (leftHand, rightHand,
			handController.transform.forward);

		//Debug.Log (angle);

		if (Math.Abs (angle) >= minAngle) {
			return true;
		}

		return false;
	}
Example #54
0
 // Use this for initialization
 void Start()
 {
     player = GetComponentInParent<PlayerController> ();
     leftHand = GetComponentInChildren<LeftHandController> ();
     hand = GetComponentInChildren<HandController> ();
 }
Example #55
0
 public void SetController(HandController controller)
 {
     controller_ = controller;
 }
 public void SetController(HandController Controller) {
   Controller_ = Controller;
 }
Example #57
0
    void Start()
    {
        leftArrow = GameObject.Find("LeftArrow").GetComponent<DirrectionLightUp>();
        rightArrow = GameObject.Find("RightArrow").GetComponent<DirrectionLightUp>();
        upArrow = GameObject.Find("UpArrow").GetComponent<DirrectionLightUp>();
        downArrow = GameObject.Find("DownArrow").GetComponent<DirrectionLightUp>();
        cameraStartingPosition = transform.position;
        cameraStartingRotation = transform.rotation;
        delegateReference = new LeapEventDelegate(parseFrameAndRotate);
        cameraMovementVector = new Vector3(0, 0, 0);
        cameraRotationVector = new Vector3(0, 0, 0);
        fingerVectors = new Vector3[5];
        GameObject ballGameObject = GameObject.Find("Ball");
        if(ballGameObject != null) {
            ball = ballGameObject.transform;
            ballsRigidbody = ball.GetComponent<Rigidbody>();
        }

        leftHandControllerTransform = GameObject.FindGameObjectWithTag("LeftHand").transform;
        rightHandControllerTransform = GameObject.FindGameObjectWithTag("RightHand").transform;
        leftHandController = leftHandControllerTransform.gameObject.GetComponent<HandController>();
        rightHandController = rightHandControllerTransform.gameObject.GetComponent<HandController>();

        leftHandControllerStartingPosition = leftHandControllerTransform.position;
        leftHandControllerStartingRotation = leftHandControllerTransform.rotation;
        rightHandControllerStartingPosition = rightHandControllerTransform.position;
        rightHandControllerStartingRotation = rightHandControllerTransform.rotation;
        BallsSpeed = 150f;
        offset = 0;
    }
Example #58
0
    void Start()
    {
        HandController[] allControllers = FindObjectsOfType<HandController> ();
        foreach (HandController controller in allControllers) {
          if (controller.isActiveAndEnabled) {
        handController = controller;
          }
        }
        if (handController == null) {
          Debug.LogWarning ("Camera alignment requires an active HandController in the scene -> enabled = false");
          enabled = false;
          return;
        }

        LeapImageRetriever[] allRetrievers = FindObjectsOfType<LeapImageRetriever> ();
        foreach (LeapImageRetriever retriever in allRetrievers) {
          if (retriever.isActiveAndEnabled) {
        imageRetriever = retriever;
          }
        }
        /*if (imageRetriever == null) {
          Debug.LogWarning ("Camera alignment requires an active LeapImageRetriever in the scene -> enabled = false");
          enabled = false;
          return;
        }*/

        hasCameras = VRCameras.NONE;
        if (centerCamera != null) {
          Camera center = centerCamera.GetComponent<Camera>();
          if (center != null && center.isActiveAndEnabled) {
        hasCameras = VRCameras.CENTER;
          }
        }
        if (hasCameras == VRCameras.NONE) {
          Camera left = leftCamera.GetComponent<Camera>();
          Camera right = rightCamera.GetComponent<Camera>();
          if (left != null && left.isActiveAndEnabled &&
          right != null && right.isActiveAndEnabled) {
        hasCameras = VRCameras.LEFT_RIGHT;
          }
        }
        if (hasCameras == VRCameras.NONE) {
          Debug.LogWarning ("Either a central Camera for both eyes, or a Left and Right cameras must be referenced -> enabled = false");
          enabled = false;
          return;
        }

        if (transform.parent == null) {
          Debug.LogWarning ("Alignment requires a parent object to define the location of the player in the world. enabled -> false");
          enabled = false;
          return;
        }

        if (transform != leftCamera.parent ||
        transform != centerCamera.parent ||
        transform != rightCamera.parent) {
          Debug.LogWarning ("LeapCameraAlignment must be a component of the parent of the camera tranasforms -> enabled = false");
          enabled = false;
          return;
        }

        deviceInfo = (overrideDeviceType) ? new LeapDeviceInfo(overrideDeviceTypeWith) : handController.GetDeviceInfo ();
        if (deviceInfo.type == LeapDeviceType.Invalid) {
          Debug.LogWarning ("Invalid Leap Device -> enabled = false");
          enabled = false;
          return;
        }

        if (VRDevice.isPresent &&
        VRSettings.loadedDevice == VRDeviceType.Oculus) {
          eyeAlignment = new UserEyeAlignment() {
        use = true,
        ipd = OVRPlugin.ipd,
        eyeDepth = OVRPlugin.eyeDepth,
        eyeHeight = OVRPlugin.eyeHeight
          };
          Debug.Log ("Unity VR Support with Oculus");
        } else {
          eyeAlignment = new UserEyeAlignment() {
        use = false,
        ipd = 0f,
        eyeDepth = 0f,
        eyeHeight = 0f
          };
          Debug.Log ("Two-camera stereoscopic alignment");
        }
    }
	// Use this for initialization
	void Start () {

		handController = GetComponent<HandController> ();
	
	}
Example #60
0
 void Start()
 {
     Create();
     hand_controller_ = GameObject.Find("HandController").GetComponent<HandController>();
 }