예제 #1
0
    public void startTRSGizmo(GameObject o)
    {
        gizmoScript = (GyzmoTransformScript)gizmoChild.GetComponent(typeof(GyzmoTransformScript));


        //gizmoLight.SetActive (true);
        gizmoChild.SetActive(true);
        gizmoCamera.SetActive(true);
        gizmoScript.startGizmoAttachment(o);
        Transform mainCamera = transform.Find("Main Camera");

        ScaleCamera  scale  = (ScaleCamera)mainCamera.GetComponent(typeof(ScaleCamera));
        RotateCamera rotate = (RotateCamera)mainCamera.GetComponent(typeof(RotateCamera));

        rotate.setPoint(o);

        LinkGyzmoPositionToPointPosition link = (LinkGyzmoPositionToPointPosition)gizmoChild.GetComponent(typeof(LinkGyzmoPositionToPointPosition));

        link.SetPoint(o);


        SelectorScript selectorScript = (SelectorScript)selector.GetComponent(typeof(SelectorScript));

        selectorScript.setPoint(o);


        scale.SetFocusPoint(o);



        active = true;         //JT

        gizmoCamera.transform.position = viewerCamera.transform.position;
        gizmoCamera.transform.rotation = viewerCamera.transform.rotation;
    }
예제 #2
0
 private void Awake()
 {
     rb               = transform.root.GetComponent <Rigidbody2D>();
     lineRenderer     = GetComponent <SpriteRenderer>();
     triangleRenderer = triangle.GetComponent <SpriteRenderer>();
     circleRenderer   = circle.GetComponent <SpriteRenderer>();
     gravScript       = target.GetComponent <GravityApplier>();
     selector         = transform.root.GetComponent <SelectorScript>();
 }
    void Start()
    {
        GameObject s = GameObject.Find("Selector");

        selector = (SelectorScript)s.GetComponent(typeof(SelectorScript));

        mr = GetComponent <MeshRenderer> ();

        init = mr.material;
    }
예제 #4
0
 //stating the sprites
 private void Awake()
 {
     if (instance != null && instance != this)
     {
         Destroy(this.gameObject);
     }
     else
     {
         instance = this;
     }
 }
예제 #5
0
    void Start()
    {
        foreach (GameObject rectangle in GameObject.FindGameObjectsWithTag("Rectangles"))
        {
            //if (rectangle.gameObject.name == "FocusRectangle")
            //FocusSprite = rectangle.GetComponent<FocusRectangleObject>();
            if (rectangle.gameObject.name == "SelectionRectangle")
            {
                SelectionSprite = rectangle.GetComponent <SelectorScript>();
            }
            else if (rectangle.gameObject.name == "GroupRectangle")
            {
                GroupSprite = rectangle.GetComponent <GroupRectangleScript>();
            }
        }

        MouseEvents.Setup(gameObject);

        SelectedGroup = ScriptableObject.CreateInstance <UnitGroup>();
        SelectedGroup.startGroup();

        //scrolling = (GetComponent<Scrolling>()) ? GetComponent<Scrolling>() : null;

        //if (camera.name == null)
        //{
        camera = Camera.main;
        //}
        Scale = new Vector2((camera.pixelRect.width / gameObject.guiTexture.texture.width), (camera.pixelRect.height / gameObject.guiTexture.texture.height));


        //gameObject.guiTexture.pixelInset = new Rect(0, -camera.pixelHeight, camera.pixelWidth, camera.pixelHeight);
        //if (gameObject.GetComponent<GUIText>() == null) gameObject.AddComponent<GUIText>();

        gameObject.guiText.pixelOffset = new Vector2(-Camera.main.pixelWidth / 2 + 25 * Scale.x, Camera.main.pixelHeight / 2 - 80 * Scale.y);
        MapViewArea = new Rect(20 * Scale.x, 20 * Scale.y, 1675 * Scale.x, 1047 * Scale.y);
        MainGuiArea = new Rect(1716 * Scale.x, 20 * Scale.y, 184 * Scale.x, 1047 * Scale.y);
        gameObject.guiText.fontSize = (int)(40f * Scale.x + 0.5f);

        //guiTexture.pixelInset = MapViewArea;
        //guiTexture.guiTexture.border.left = (int)(20f * Scale.x);
        //guiTexture.guiTexture.border.right = (int)(225f * Scale.x);
        //guiTexture.guiTexture.border.top = (int)(20f * Scale.y);
        //guiTexture.guiTexture.border.bottom = (int)(13f * Scale.y);


        //QamAcsess = Camera.main.GetComponent<camScript>();

        MouseEvents.LEFTCLICK   += MouseEvents_LEFTCLICK;
        MouseEvents.RIGHTCLICK  += MouseEvents_RIGHTCLICK;
        MouseEvents.LEFTRELEASE += MouseEvents_LEFTRELEASE;

        UpdateManager.GUIUPDATE += UpdateManager_GUIUPDATE;
    }
예제 #6
0
    private void SetupSelector()
    {
        SelectorScript selectorScript = selectorObject.GetComponent <SelectorScript>();

        selectorScript.SetOnScreenControlsRef(screenControls);

        foreach (ContactMeLink contact in contacts)
        {
            contact.SetLinkVerification(ref linkVerificationScript);
            selectorScript.AddNewAction(contact.description, contact.selectorAction, selectorHyperlink);
            selectorScript.InicializeInteractive();
        }

        InteractionObject interactionObject = selectorObject.GetComponent <InteractionObject>();

        interactionObject.SetDelegateDown(selectorScript.NextAction);
        interactionObject.SetDelegateUp(selectorScript.PreviousAction);
        interactionObject.SetDelegateInteract(selectorScript.UseCurrentAction);
        interactionObject.SetDelegateStart(selectorScript.OnStartAction);
        interactionObject.SetDelegateEnd(selectorScript.OnEndAction);
    }
예제 #7
0
    void RotateCubesMouse()
    {
        if (!rotating)//dont allow clicks if rotating
        {
            if (cameraController.zoomOut)
            {
                //raycast for clicks
                ray = Camera.main.ScreenPointToRay(Input.mousePosition);
                if (Physics.Raycast(ray, out hit))
                {
                    if (Input.GetMouseButtonDown(0))
                    {
                        //checks if it hit a selector
                        if (hit.collider.tag == "Selector")
                        {
                            //starts the recording of mouse inputs so we can see what direction is rotated
                            selectorScript  = hit.collider.gameObject.GetComponent <SelectorScript>();
                            holdingSelector = true;
                            totalMouseX     = 0;
                            totalMouseY     = 0;
                        }
                    }
                    else
                    {
                        if (hit.collider.tag == "Selector")
                        {
                            //Hilights rows
                            ClearPlanes();
                            selectorScript = hit.collider.gameObject.GetComponent <SelectorScript>();
                            selectorScript.planeVert.GetComponent <Renderer>().enabled = true;
                            selectorScript.planeHor.GetComponent <Renderer>().enabled  = true;
                            planesToRemove.Add(selectorScript.planeVert);
                            planesToRemove.Add(selectorScript.planeHor);

                            lockHor = SetMats(Physics.OverlapBox(selectorScript.cubeSideHor.transform.position, selectorScript.cubeSideHor.transform.localScale / 2, Quaternion.identity), selectorScript.planeHor);

                            lockVert = SetMats(Physics.OverlapBox(selectorScript.cubeSideVert.transform.position, selectorScript.cubeSideVert.transform.localScale / 2, Quaternion.identity), selectorScript.planeVert);
                        }
                        else
                        {
                            ClearPlanes();
                        }
                    }
                }
                else
                {
                    ClearPlanes();
                }
                //cancels recording of mouse if mouse is released
                if (Input.GetMouseButtonUp(0))
                {
                    holdingSelector = false;
                }
                if (holdingSelector)//records mouse inputs and checks if it has moved far enough
                {
                    totalMouseX += Input.mousePosition.x - lastMouseX;
                    totalMouseY += Input.mousePosition.y - lastMouseY;


                    if (Mathf.Abs(totalMouseX) > 20 && !lockHor)/////////////////////HORIZONTAL ROTATION/////////////////////////////////
                    {
                        //gets all objects collided with the cube row
                        Collider[] hitColliders = Physics.OverlapBox(selectorScript.cubeSideHor.transform.position, selectorScript.cubeSideHor.transform.localScale / 2, Quaternion.identity);
                        int        i            = 0;
                        while (i < hitColliders.Length)
                        {
                            if (hitColliders[i].tag == "RuCube")                                                      //checks if its a cube
                            {
                                hitColliders[i].gameObject.transform.SetParent(selectorScript.cubeSideHor.transform); //parents the cube to the row
                                                                                                                      //sets the cubes to rotate
                                objectToRotate  = selectorScript.cubeSideHor;
                                rotating        = true;
                                rotateVert      = false;
                                rotationNeeded  = 90;
                                holdingSelector = false;
                                ClearPlanes();
                                //gets the direction to rotate
                                if (totalMouseX > 0)
                                {
                                    rotateDirection = -1f;
                                }
                                else
                                {
                                    rotateDirection = 1f;
                                }
                            }
                            //Increase the number of Colliders in the array
                            i++;
                        }
                    }
                    if (Mathf.Abs(totalMouseY) > 20 && !lockVert)/////////////////////VERTICLE ROTATION/////////////////////////////////
                    {
                        //gets all objects collided with the cube row
                        Collider[] hitColliders = Physics.OverlapBox(selectorScript.cubeSideVert.transform.position, selectorScript.cubeSideVert.transform.localScale / 2, Quaternion.identity);
                        int        i            = 0;
                        while (i < hitColliders.Length)
                        {
                            if (hitColliders[i].tag == "RuCube")                                                       //checks if its a cube
                            {
                                hitColliders[i].gameObject.transform.SetParent(selectorScript.cubeSideVert.transform); //parents the cube to the row
                                                                                                                       //sets the cubes to rotate
                                objectToRotate  = selectorScript.cubeSideVert;
                                rotating        = true;
                                rotateVert      = true;
                                rotationNeeded  = 90;
                                holdingSelector = false;
                                ClearPlanes();
                                //gets the direction to rotate
                                if (totalMouseY > 0)
                                {
                                    rotateDirection = 1f;
                                }
                                else
                                {
                                    rotateDirection = -1f;
                                }
                            }
                            //Increase the number of Colliders in the array
                            i++;
                        }
                    }
                }
            }
            else
            {
                ClearPlanes();
            }
        }
        else
        {
            if (!rotateTo)
            {
                if (Input.GetMouseButtonUp(0))
                {
                    //print(objectToRotate.transform.rotation.eulerAngles.x);

                    rotateTo = true;
                    step     = 0;


                    if (rotateVert)
                    {
                        mouseVel = Mathf.Clamp(Input.mousePosition.y - lastMouseY, -50f, 50f);
                    }
                    else
                    {
                        mouseVel = Mathf.Clamp(Input.mousePosition.x - lastMouseX, -40f, 40f);
                    }
                    mouseVelTime = 0.12f;
                }

                if (rotateVert)
                {
                    objectToRotate.transform.Rotate(Vector3.right * (Mathf.Clamp(Input.mousePosition.y - lastMouseY, -50f, 50f) / 5.5f));
                }
                else
                {
                    objectToRotate.transform.Rotate(Vector3.up * -(Mathf.Clamp(Input.mousePosition.x - lastMouseX, -40f, 40f) / 5.5f));
                }
            }
            else
            {
                if (mouseVelTime > 0)
                {
                    if (rotateVert)
                    {
                        objectToRotate.transform.Rotate(Vector3.right * mouseVel / 5.5f);
                    }
                    else
                    {
                        objectToRotate.transform.Rotate(Vector3.up * -mouseVel / 5.5f);
                    }
                    mouseVelTime   -= Time.deltaTime;
                    startAngle      = objectToRotate.transform.eulerAngles;
                    vecToRotateTo   = objectToRotate.transform.eulerAngles;
                    vecToRotateTo.x = Mathf.Round(vecToRotateTo.x / 90) * 90;
                    vecToRotateTo.y = Mathf.Round(vecToRotateTo.y / 90) * 90;
                    vecToRotateTo.z = Mathf.Round(vecToRotateTo.z / 90) * 90;
                }
                else
                {
                    step += 0.1f;
                    objectToRotate.transform.eulerAngles = new Vector3(
                        Mathf.LerpAngle(startAngle.x, vecToRotateTo.x, step),
                        Mathf.LerpAngle(startAngle.y, vecToRotateTo.y, step),
                        Mathf.LerpAngle(startAngle.z, vecToRotateTo.z, step));
                    if (step >= 1)
                    {
                        //ends rotation and detaches children
                        rotating = false;
                        rotateTo = false;
                        objectToRotate.transform.DetachChildren();
                        GameManager.gameDaddy.blockCollision.setBlockCollision();
                    }
                }
            }

            /*
             * if (rotationNeeded > 0)//rotates cubes over time
             * {
             *
             *
             * float changeSpeed = 5;//NEEDS TO BE A MULTAPUL OF 90
             * //checks if rows or colums need to be rotated
             * if (rotateVert)
             * {
             *     objectToRotate.transform.Rotate(Vector3.right * changeSpeed * rotateDirection);
             * }
             * else
             * {
             *     objectToRotate.transform.Rotate(Vector3.up * changeSpeed * rotateDirection);
             * }
             * rotationNeeded += -changeSpeed;
             * }
             * else
             * {
             * //ends rotation and detaches children
             * rotating = false;
             * objectToRotate.transform.DetachChildren();
             * }
             */
        }

        //gets mouse location to calculate change
        lastMouseX = Input.mousePosition.x;
        lastMouseY = Input.mousePosition.y;
    }
예제 #8
0
 private void Awake()
 {
     Instance = this;
 }
예제 #9
0
    void Start()
    {
        foreach (GameObject rectangle in GameObject.FindGameObjectsWithTag("Rectangles"))
        {
            //if (rectangle.gameObject.name == "FocusRectangle")
                //FocusSprite = rectangle.GetComponent<FocusRectangleObject>();
            if (rectangle.gameObject.name == "SelectionRectangle")
                SelectionSprite = rectangle.GetComponent<SelectorScript>();
            else if (rectangle.gameObject.name == "GroupRectangle")
                GroupSprite = rectangle.GetComponent<GroupRectangleScript>();
        }
        
        MouseEvents.Setup(gameObject);

        SelectedGroup = ScriptableObject.CreateInstance<UnitGroup>();
        SelectedGroup.startGroup();

        //scrolling = (GetComponent<Scrolling>()) ? GetComponent<Scrolling>() : null;
        
        //if (camera.name == null)
        //{
        camera = Camera.main;
        //}
        Scale = new Vector2((camera.pixelRect.width / gameObject.guiTexture.texture.width), (camera.pixelRect.height / gameObject.guiTexture.texture.height));


        //gameObject.guiTexture.pixelInset = new Rect(0, -camera.pixelHeight, camera.pixelWidth, camera.pixelHeight);
        //if (gameObject.GetComponent<GUIText>() == null) gameObject.AddComponent<GUIText>();

        gameObject.guiText.pixelOffset = new Vector2(-Camera.main.pixelWidth / 2 + 25 * Scale.x, Camera.main.pixelHeight/2 - 80 * Scale.y);
        MapViewArea = new Rect(20 * Scale.x, 20 * Scale.y, 1675 * Scale.x, 1047 * Scale.y);
        MainGuiArea = new Rect(1716 * Scale.x, 20 * Scale.y, 184 * Scale.x, 1047 * Scale.y);
        gameObject.guiText.fontSize = (int)(40f * Scale.x + 0.5f);

        //guiTexture.pixelInset = MapViewArea;
        //guiTexture.guiTexture.border.left = (int)(20f * Scale.x);
        //guiTexture.guiTexture.border.right = (int)(225f * Scale.x);
        //guiTexture.guiTexture.border.top = (int)(20f * Scale.y);
        //guiTexture.guiTexture.border.bottom = (int)(13f * Scale.y);


        //QamAcsess = Camera.main.GetComponent<camScript>();

        MouseEvents.LEFTCLICK += MouseEvents_LEFTCLICK;
        MouseEvents.RIGHTCLICK += MouseEvents_RIGHTCLICK;
        MouseEvents.LEFTRELEASE += MouseEvents_LEFTRELEASE;

        UpdateManager.GUIUPDATE += UpdateManager_GUIUPDATE;

        
    }
 void Start()
 {
     objSelected = null;
     selected = false;
     agentSelector = GetComponent<SelectorScript> ();
 }