Beispiel #1
0
    /// <summary>
    /// 获取目标点(NPC)周围的随机一个可站立点
    /// </summary>
    public static Vector3 GetRandomPos(Vector3 _tarVector3)
    {
        if (_tarVector3.Equals(Vector3.zero))
        {
            return(Vector3.zero);
        }
        List <Vector3> posList = new List <Vector3>();
        Vector3        pos     = _tarVector3;

        posList.Add(new Vector3(pos.x + 1, 0, pos.z));
        posList.Add(new Vector3(pos.x + 1, 0, pos.z + 1));
        posList.Add(new Vector3(pos.x + 1, 0, pos.z - 1));
        posList.Add(new Vector3(pos.x - 1, 0, pos.z));
        posList.Add(new Vector3(pos.x - 1, 0, pos.z + 1));
        posList.Add(new Vector3(pos.x - 1, 0, pos.z - 1));
        posList.Add(new Vector3(pos.x, 0, pos.z));
        posList.Add(new Vector3(pos.x, 0, pos.z + 1));
        posList.Add(new Vector3(pos.x, 0, pos.z - 1));
        Vector3 initPos = Vector3.zero;

        for (int i = 0; i < posList.Count; i++)
        {
            if (GameStageUtility.CheckPosition(pos, posList[i]))
            {
                initPos = posList[i];
                break;
            }
        }
        if (initPos == Vector3.zero)
        {
            initPos = pos;
        }
        return(initPos);
    }
Beispiel #2
0
    /// <summary>
    /// 获取主角身边的随机一个可站立点
    /// </summary>
    public static Vector3 GetRandomPos(Transform _tar)
    {
        if (_tar == null)
        {
            return(Vector3.zero);
        }
        List <Vector3> posList = new List <Vector3>();
        Vector3        pos     = _tar.position;

        posList.Add(new Vector3(pos.x + 1, 0, pos.z));
        posList.Add(new Vector3(pos.x + 1, 0, pos.z + 1));
        posList.Add(new Vector3(pos.x + 1, 0, pos.z - 1));
        posList.Add(new Vector3(pos.x - 1, 0, pos.z));
        posList.Add(new Vector3(pos.x - 1, 0, pos.z + 1));
        posList.Add(new Vector3(pos.x - 1, 0, pos.z - 1));
        posList.Add(new Vector3(pos.x, 0, pos.z));
        posList.Add(new Vector3(pos.x, 0, pos.z + 1));
        posList.Add(new Vector3(pos.x, 0, pos.z - 1));
        Vector3 initPos = Vector3.zero;

        System.Random random = new System.Random();
        while (posList.Count > 0)       //用随机,否则都是一个点
        {
            int count = posList.Count;
            int index = random.Next(0, count - 1);
            if (GameStageUtility.CheckPosition(pos, posList[index]))
            {
                initPos = posList[index];
                break;
            }
            else
            {
                posList.RemoveAt(index);
            }
        }
        if (initPos == Vector3.zero)
        {
            initPos = pos;
        }
        return(ActorMoveFSM.LineCast(initPos, true));
    }
Beispiel #3
0
        static int _m_CheckPosition_xlua_st_(RealStatePtr L)
        {
            ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);



            try {
                {
                    UnityEngine.Vector3 _from; translator.Get(L, 1, out _from);
                    UnityEngine.Vector3 _to; translator.Get(L, 2, out _to);

                    bool __cl_gen_ret = GameStageUtility.CheckPosition(_from, _to);
                    LuaAPI.lua_pushboolean(L, __cl_gen_ret);



                    return(1);
                }
            } catch (System.Exception __gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e));
            }
        }