Example #1
0
    public void UseMode()
    {    //Uses the object on right click
        Ray ray;

        if (MouseLookEnabled == true)
        {
            ray = Camera.main.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0f));           //This is a vector to the center of the window
        }
        else
        {
            ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        }
        RaycastHit hit = new RaycastHit();

        if (Physics.Raycast(ray, out hit, GetUseRange()))
        {
            ObjectInteraction objPicked;
            objPicked = hit.transform.GetComponent <ObjectInteraction>();

            if (objPicked != null)
            {
                objPicked.Use();
            }
            else
            {            //Special case for portcullises
                if (hit.transform.GetComponent <PortcullisInteraction>() != null)
                {
                    objPicked = hit.transform.GetComponent <PortcullisInteraction>().getParentObjectInteraction();
                    if (objPicked != null)
                    {
                        objPicked.Use();
                        UWHUD.instance.window.UWWindowWait(1.0f);
                    }
                }
                else if (hit.transform.parent == GameWorldController.instance.LevelModel.transform)
                {
                    if (EditorMode)
                    {
                        string[] tilenamePortions = hit.transform.name.Split('_');
                        int      tileX            = int.Parse(tilenamePortions[1]);
                        int      tileY            = int.Parse(tilenamePortions[2]);
                        if (IngameEditor.FollowMeMode)
                        {
                            IngameEditor.UpdateFollowMeMode(tileX, tileY);
                        }
                        else
                        {
                            IngameEditor.instance.SelectTile(tileX, tileY);
                        }
                    }
                }
            }
        }
    }
Example #2
0
 void Awake()
 {
     instance = this;
 }