Esempio n. 1
0
        private static T NullableHelper <T>() where T : struct
        {
            Nullable.Compare <T>(null, null);
            Nullable.Equals <T>(null, null);
            Nullable <T> nullable = new Nullable <T>();

            return(nullable.GetValueOrDefault());
        }
Esempio n. 2
0
        static T NullableHelper_HACK <t>() where T : struct
        {
            Nullable.Compare <t>(null, null);
            Nullable.Equals <t>(null, null);
            Nullable <t> nullable = new Nullable <t>();

            return(nullable.GetValueOrDefault());
        }
Esempio n. 3
0
    public static Vector3 ScreenMouseToGround(Vector3 heroPosition)
    {
        Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);

        RaycastHit[] hitList = Physics.RaycastAll(ray, 200);
        System.Array.Sort(hitList, delegate(RaycastHit r1, RaycastHit r2) { return(r1.distance.CompareTo(r2.distance)); });
        System.Nullable <RaycastHit> heroHit = null;
        foreach (RaycastHit hit in hitList)
        {
            if (hit.collider.gameObject.tag == TagManager.GetInstance().NavMeshTag)
            {
                //Debug.Log("get hit "+hit.collider.gameObject.name + " " + hit.distance);
                return(KingSoftCommonFunction.NearPosition(hit.point));
            }
            else
            {
                //Debug.Log("hit "+hit.collider.gameObject.name + " " + hit.distance);
                heroHit = hit;
            }
        }
        if (null != heroHit)
        {
            return(NearPosition(heroHit.GetValueOrDefault().point));
        }
        if (null == plane)
        {
            plane = new GameObject();
            GameObject.DontDestroyOnLoad(plane);
            BoxCollider box = plane.AddComponent <BoxCollider>();
            plane.tag  = TagManager.GetInstance().NavMeshTag;
            box.center = Vector3.zero;
            box.size   = new Vector3(1000f, 1, 1000f);
        }

        {
            plane.transform.position = heroPosition - Vector3.down - Vector3.down;
            plane.SetActive(true);
            ray     = Camera.main.ScreenPointToRay(Input.mousePosition);
            hitList = Physics.RaycastAll(ray, 200);
            foreach (RaycastHit hit in hitList)
            {
                if (hit.collider.gameObject.tag == TagManager.GetInstance().NavMeshTag)
                {
                    plane.SetActive(false);
                    return(NearPosition(hit.point, 2f));
                }
            }
            plane.SetActive(false);
        }
        return(NearPosition(Vector3.zero, 100000f));
    }