예제 #1
0
    public virtual void OnInputClicked(HoloToolkit.Unity.InputModule.InputClickedEventData eventData)
    {
        GameObject        map      = GameObject.FindWithTag("Map");
        List <GameObject> ennemies = this.transform.GetChild(0).gameObject.GetComponent <AttackTowerScript>().enemiesInRange;

        clearEnemies(ennemies);
        Destroy(this.transform.GetChild(0).gameObject);
        GameObject tmpObj = Instantiate(tower, this.transform.position, Quaternion.identity, map.transform);

        tmpObj.tag = "BusyForObj";
        int i = 0;

        var render = this.GetComponentsInChildren <Renderer>();

        this.gameObject.SetActive(false);
    }
예제 #2
0
 /// <summary>
 /// Function for receiving OnInputClicked events from InputManager
 /// </summary>
 /// <param name="eventData"></param>
 public virtual void OnInputClicked(InputClickedEventData eventData)
 {
     // Open input socket for other cool stuff...
 }
예제 #3
0
 public virtual void OnInputClicked(InputClickedEventData eventData)
 {
     // On each tap gesture, toggle whether the user is in placing mode.
     IsBeingPlaced = !IsBeingPlaced;
     HandlePlacement();
 }
예제 #4
0
        public void OnInputClicked(InputClickedEventData eventData)
        {
            currentObj = transform.gameObject;
            if (previousObj != currentObj || previousObj != null && currentObj.tag == "light")
            {
                menu.transform.position = currentObj.transform.position;
            }

            if (!GameObject.FindGameObjectWithTag("menu"))
            {
                //				Vector3 camPos = Camera.main.transform.position;
                //				Vector3 objPos = transform.localPosition;
                //				Debug.Log ("local objPos: " + objPos);
                //				Vector3 upObjPos = objPos + transform.up;
                //
                //
                //
                //				Vector3 camObjDiff = camPos - objPos;
                //				Vector3 upObjDiff = upObjPos - objPos;
                //				Vector3 perpPos = Vector3.Cross (upObjDiff, camObjDiff).normalized;
                //
                //				Debug.DrawLine (camPos, objPos, Color.red, 120);
                //				Debug.DrawLine (upObjPos, objPos, Color.green, 120);
                //				Debug.DrawLine (perpPos, objPos, Color.blue, 120);
                //
                //
                //				menu.transform.position = perpPos;
                //				menu.transform.rotation = transform.rotation;
                menu.SetActive(true);
                Debug.Log("menu state: (true);" + menu.activeSelf);
            }
            else
            {
                menu.SetActive(false);
                Debug.Log("menu.SetActive (false);" + menu.activeSelf);
            }

            /*
             *              Vector3 offset = new Vector3 (0.01f, 0.01f, 0.01f);
             *              // Set menu position adjacent to gameObject
             *              Vector3 camPos = Camera.main.transform.position;
             *              Debug.Log ("camPos: " + camPos);
             *
             *              Vector3 objPos = gameObject.transform.position;
             *              Vector3 upObjPos = gameObject.transform.position + gameObject.transform.up;
             *
             *              Vector3 camObjDiff = camPos - objPos;
             *
             *              Debug.DrawLine (camPos, objPos, Color.red, 120);
             *              Debug.Log ("camPos: " + camPos);
             *              Debug.Log ("objPos: " + objPos);
             *              Debug.Log ("camObjDiff: " + camObjDiff);
             *
             *              Vector3 upObjDiff = upObjPos - objPos;
             *
             *              Debug.DrawLine (upObjPos, objPos, Color.green, 120);
             *              Debug.Log ("upObjPos: " + upObjPos);
             *              Debug.Log ("objPos: " + objPos);
             *              Debug.Log ("upObjDiff: " + upObjDiff);
             *
             *              Vector3 perpPos = Vector3.Cross (upObjDiff, camObjDiff);
             *              perpPos += objPos;
             *
             *              Debug.DrawLine (perpPos, objPos, Color.blue, 120);
             *              Debug.Log ("perpPos: " + perpPos);
             *
             *              Vector3 camPos = new Vector3 (0.35f, -0.02f, -3.48f);
             *              Vector3 upObjPos = new Vector3 (2.42f, 3.22f, -2.14f);
             *              Vector3 objPos = new Vector3 (2.42f, 2.0f, -2.14f);
             *
             *
             *              Debug.Log (this.gameObject+ " should be looking at you");
             */



//
//			menu.transform.Translate (Vector3.ClampMagnitude( (Camera.main.transform.position -menu.transform.position).normalized,1) * .8f,Space.Self);
//			menu.transform.Translate (Vector3.right *2f, Space.World);
//
            Vector3 dir = Camera.main.transform.right;

            dir.y = transform.position.y;
            dir.Normalize();


            menu.transform.position = gameObject.transform.position;
            menu.transform.Translate(dir * .2f);


            menu.transform.LookAt(Camera.main.transform);
            menu.transform.RotateAround(menu.transform.position, menu.transform.up, 180f);


            //menu.transform.position = gameObject.transform.position + MenuOffSet;

            previousObj = transform.gameObject;
        }
예제 #5
0
 public virtual void OnInputClicked(InputClickedEventData eventData)
 {
     HandlePlacement();
 }
예제 #6
0
파일: Cursor.cs 프로젝트: weiwu-csu/MR_NSF
 /// <summary>
 /// Function for receiving OnInputClicked events from InputManager
 /// </summary>
 /// <param name="eventData"></param>
 public virtual void OnInputClicked(InputClickedEventData eventData)
 {
     // Open input socket for other cool stuff...
     //Debug.Log("cursor position" + transform.position);
 }
예제 #7
0
 public virtual void OnInputClicked(InputClickedEventData eventData)
 {
     return;
 }
예제 #8
0
        public void OnInputClicked(InputModule.InputClickedEventData eventData)
        {
            GameObject targeted = InputModule.FocusManager.Instance.TryGetFocusedObject(eventData);

            foreach (KeyValuePair <string, GameObject> b in buttons)
            {
                if (targeted == b.Value)
                {
                    switch (b.Key)
                    {
                    case "MoveWithMe":
                        MoveWithMe = !MoveWithMe;
                        break;

                    case "DepthDebug":
                        DepthDebug = !DepthDebug;
                        break;

                    case "ShowCursor":
                        ShowCursor = !ShowCursor;
                        break;

                    case "AutoDistance":
                        if (CaptionDistance == 0)
                        {
                            CaptionDistance = 1;
                        }
                        else if (CaptionDistance == 1)
                        {
                            CaptionDistance = 2;
                        }
                        else if (CaptionDistance == 2)
                        {
                            CaptionDistance = 4;
                        }
                        else if (CaptionDistance == 4)
                        {
                            CaptionDistance = 8;
                        }
                        else
                        {
                            CaptionDistance = 0;
                        }
                        break;

                    case "TextSize":
                        TextSize = (TextSize + 1) % 3;
                        break;

                    case "TextLines":
                        TextLines = (TextLines % 5) + 1;
                        break;

                    case "TextLineLength":
                        TextLineLength += 20;
                        if (TextLineLength > 80)
                        {
                            TextLineLength = 40;
                        }
                        break;
                    }

                    settings_set = false;

                    eventData.Use();
                    return;
                }
            }


            if (captions.Count > 1)
            {
                for (int i = captions.Count - 1; i >= 0; i--)
                {
                    GameObject o = captions[i];
                    if (o.GetComponent <GlassEarTagalong>().frozen&& targeted == o)
                    {
                        captions.RemoveAt(i);
                        Destroy(o);

                        eventData.Use();
                        return;
                    }
                }
            }

            foreach (GameObject o in captions)
            {
                if (!o.GetComponent <GlassEarTagalong>().frozen)
                {
                    o.GetComponent <GlassEarTagalong>().frozen = true;

                    eventData.Use();
                    return;
                }
            }

            GameObject newO = Instantiate(captions[0]);

            newO.GetComponent <GlassEarTagalong>().frozen = false;
            newO.transform.SetParent(transform);
            captions.Add(newO);

            eventData.Use();
            return;
        }
예제 #9
0
 public override void OnInputClicked(InputClickedEventData eventData)
 {
     PlaceMarker();
 }
예제 #10
0
        public void OnInputClicked(InputClickedEventData eventData)
        {
            Light light = OpenMenu.currentObj.GetComponentInChildren <Light>();
            float red   = 0.0f;
            float green = 0.0f;
            float blue  = 0.0f;
            float alpha = 0.0f;


            switch (type)
            {
            case Type.addLight:

                Debug.Log("Clicked Add Light");
                Vector3 newPos = transform.position;
                newPos.y = transform.position.y + 0.1f;
                GameObject newChild = Instantiate(prefabLight, newPos, Quaternion.identity) as GameObject;
                Random.seed = System.DateTime.Now.Millisecond;
                int randomNumber = (int)Random.Range(0.0f, 100000.0f);
                newChild.name = randomNumber.ToString();

                // Add to dictionary
                lightDict.Add(randomNumber, newChild);

                PrintDictionary();
                break;

            case Type.removeLight:
                Debug.Log("clicked remove light button");

                if (lightDict.Count > 0)
                {
                    lightDict.Remove(int.Parse(OpenMenu.currentObj.name));
                    Destroy(OpenMenu.currentObj);
                    Debug.Log("Removed light");
                }
                else
                {
                    Debug.Log("You can't delete your last light");
                }
                PrintDictionary();

//				if (gameObj == null){
//					lightsArray.Find(item => item.name == buttonName).SetActive(true);
//					hiddenObjects.Remove(gameObj);
//				}
//				else{
//					hiddenObjects.Add(gameObj);
//					gameObj.SetActive (false);
//				}
                break;

            case Type.brighter:
                if (light.intensity < 8.1)
                {
                    light.intensity += 0.3f;
                }
                Debug.Log("The Light's intensity is: " + light.intensity);
                break;

            case Type.dimmer:
                if (light.intensity > 0.1)
                {
                    light.intensity -= 0.3f;
                }
                Debug.Log("The Light's intensity is: " + light.intensity);
                break;

            case Type.cooler:

                //light[0] = red
                //light[1] = green
                //light[2] = blue
                //light[3] = alpha

                red   = light.color [0] - .01f;
                green = light.color [1] - .01f;
                blue  = light.color [2] + .01f;
                alpha = light.color [3];

                light.color = new Color(red, green, blue, alpha);
                Debug.Log("The Light's color is: " + light.color);
                break;

            case Type.warmer:

                //light[0] = red
                //light[1] = green
                //light[2] = blue
                //light[3] = alpha
                // Yellow. RGBA is (1, 0.92, 0.016, 1)

                red   = light.color [0] + .01f;
                green = light.color [1] + .009f;
                blue  = light.color [2] - .01f;
                alpha = light.color [3];

                light.color = new Color(red, green, blue, alpha);
                Debug.Log("The Light's color is: " + light.color);
                break;
//			case Type.SetFrame:
//				parentObj = GameObject. FindGameObjectWithTag(buttonName).transform.parent.gameObject;
//
//				FindDistance track = new FindDistance ();
//				float distance = track.getDistanceBetween (Camera.main, parentObj);
//				//heading = parentObj.transform.position - Camera.main.transform.position;
//				//distance = Vector3.Dot (heading, Camera.main.transform.forward);
//				Camera.main.nearClipPlane = distance;
//				Debug.Log ("Distance: " + distance);
//				Debug.Log ("Near Clip Plane: " + Camera.main.nearClipPlane);
//				break;
//
//			case Type.ZoomIn:
//				parentObj = GameObject. FindGameObjectWithTag(buttonName).transform.parent.gameObject;
//
//				heading = parentObj.transform.position - Camera.main.transform.position;
//				distance = Vector3.Dot (heading, Camera.main.transform.forward);
//				Camera.main.nearClipPlane += 0.02f;
//				Debug.Log ("Distance: " + distance);
//				Debug.Log ("Near Clip Plane: " + Camera.main.nearClipPlane);
//				break;
//
//			case Type.ZoomOut :
//				parentObj = GameObject. FindGameObjectWithTag(buttonName).transform.parent.gameObject;
//
//				heading = parentObj.transform.position - Camera.main.transform.position;
//				distance = Vector3.Dot (heading, Camera.main.transform.forward);
//				Camera.main.nearClipPlane -= 0.02f;
//				Debug.Log ("Distance: " + distance);
//				Debug.Log ("Near Clip Plane: " + Camera.main.nearClipPlane);
//				break;

            default:              /* Optional */
                break;
            }
        }
예제 #11
0
        public void OnInputClicked(InputClickedEventData eventData)
        {
            string     buttonName = selection.ToString();
            GameObject gameObj    = GameObject.FindGameObjectWithTag(buttonName);
            GameObject parentObj;

            switch (type)
            {
            case Type.Lock:

                parentObj = GameObject.FindGameObjectWithTag(buttonName).transform.parent.gameObject;

                Text buttonText = gameObject.GetComponentInChildren <Text> ();
                Debug.Log("4");
                if (buttonText.text == "Lock Position")
                {
                    Debug.Log("5");
                    buttonText.text = "Unlock Position";
                    Debug.Log("6");
                    parentObj.GetComponent <HandDraggable> ().enabled = false;
                    Debug.Log("7");
                }
                else
                {
                    Debug.Log("8");
                    buttonText.text = "Lock";
                    Debug.Log("9");
                    parentObj.GetComponent <HandDraggable> ().enabled = true;
                }
                break;

            case Type.Hide:

                if (gameObj == null)
                {
                    hiddenObjects.Find(item => item.name == buttonName).SetActive(true);
                    hiddenObjects.Remove(gameObj);
                }
                else
                {
                    hiddenObjects.Add(gameObj);
                    gameObj.SetActive(false);
                }
                break;

            case Type.SetFrame:
                parentObj = GameObject.FindGameObjectWithTag(buttonName).transform.parent.gameObject;

                FindDistance track    = new FindDistance();
                float        distance = track.getDistanceBetween(Camera.main, parentObj);
                //heading = parentObj.transform.position - Camera.main.transform.position;
                //distance = Vector3.Dot (heading, Camera.main.transform.forward);
                Camera.main.nearClipPlane = distance;
                Debug.Log("Distance: " + distance);
                Debug.Log("Near Clip Plane: " + Camera.main.nearClipPlane);
                break;

            case Type.ZoomIn:
                parentObj = GameObject.FindGameObjectWithTag(buttonName).transform.parent.gameObject;

                heading  = parentObj.transform.position - Camera.main.transform.position;
                distance = Vector3.Dot(heading, Camera.main.transform.forward);
                Camera.main.nearClipPlane += 0.02f;
                Debug.Log("Distance: " + distance);
                Debug.Log("Near Clip Plane: " + Camera.main.nearClipPlane);
                break;

            case Type.ZoomOut:
                parentObj = GameObject.FindGameObjectWithTag(buttonName).transform.parent.gameObject;

                heading  = parentObj.transform.position - Camera.main.transform.position;
                distance = Vector3.Dot(heading, Camera.main.transform.forward);
                Camera.main.nearClipPlane -= 0.02f;
                Debug.Log("Distance: " + distance);
                Debug.Log("Near Clip Plane: " + Camera.main.nearClipPlane);
                break;

            default:              /* Optional */
                break;
            }
        }
예제 #12
0
 void IInputClickHandler.OnInputClicked(InputClickedEventData eventData)
 {
     HandleInputAction(eventData);
 }