Ejemplo n.º 1
0
        /// <summary>
        /// Creates a new Sim.
        /// </summary>
        /// <param name="Devc">A GraphicsDevice instance.</param>
        /// <param name="Avatar">The Avatar used for this sim (can be AdultAvatar, ChildAvatar, DogAvatar or CatAvatar.</param>
        /// <param name="Child">Is this Sim a child?</param>
        public Sim(GraphicsDevice Devc, Camera Cam, AvatarBase Avatar, bool Child = false)
        {
            IsChild  = Child;
            m_Avatar = Avatar;

            CameraController = new UICameraController(Cam);
        }
Ejemplo n.º 2
0
    public AvatarData GetTarget(AvatarBase avatar)
    {
        AvatarData _avatarData = Find(avatar.id);

        if (_avatarData == null)
        {
            return(null);
        }

        List <AvatarData> _avatarList = new List <AvatarData>(avatarDic.Values);

        if (_avatarList.Count <= 0)
        {
            return(null);
        }

        AvatarType _avatarType = AvatarType.None;

        if (_avatarData.avatarType == AvatarType.Player)
        {
            _avatarType = AvatarType.Enemy;
        }
        else
        {
            _avatarType = AvatarType.Player;
        }

        AvatarData targetData  = null;
        float      minDistance = 10000;

        for (int i = 0; i < _avatarList.Count; i++)
        {
            if (_avatarList[i].avatarType == _avatarType)
            {
                float distance = Mathf.Abs(_avatarData.avatar.tran.position.x - _avatarList[i].avatar.tran.position.x) -
                                 (_avatarData.avatar.radius + _avatarList[i].avatar.radius);


                if (distance < minDistance)
                {
                    minDistance = distance;
                    targetData  = _avatarList[i];
                }
            }
        }

        return(targetData);
    }
Ejemplo n.º 3
0
    private static int get_canRotate(IntPtr L)
    {
        object obj = null;
        int    result;

        try
        {
            obj = ToLua.ToObject(L, 1);
            AvatarBase avatarBase = (AvatarBase)obj;
            bool       canRotate  = avatarBase.canRotate;
            LuaDLL.lua_pushboolean(L, canRotate);
            result = 1;
        }
        catch (Exception ex)
        {
            result = LuaDLL.toluaL_exception(L, ex, (obj != null) ? ex.Message : "attempt to index canRotate on a nil value");
        }
        return(result);
    }
Ejemplo n.º 4
0
    private static int set_showAction(IntPtr L)
    {
        object obj = null;
        int    result;

        try
        {
            obj = ToLua.ToObject(L, 1);
            AvatarBase avatarBase = (AvatarBase)obj;
            int        showAction = (int)LuaDLL.luaL_checknumber(L, 2);
            avatarBase.showAction = showAction;
            result = 0;
        }
        catch (Exception ex)
        {
            result = LuaDLL.toluaL_exception(L, ex, (obj != null) ? ex.Message : "attempt to index showAction on a nil value");
        }
        return(result);
    }
Ejemplo n.º 5
0
    private static int set_canClick(IntPtr L)
    {
        object obj = null;
        int    result;

        try
        {
            obj = ToLua.ToObject(L, 1);
            AvatarBase avatarBase = (AvatarBase)obj;
            bool       canClick   = LuaDLL.luaL_checkboolean(L, 2);
            avatarBase.canClick = canClick;
            result = 0;
        }
        catch (Exception ex)
        {
            result = LuaDLL.toluaL_exception(L, ex, (obj != null) ? ex.Message : "attempt to index canClick on a nil value");
        }
        return(result);
    }
Ejemplo n.º 6
0
    private static int get_showAction(IntPtr L)
    {
        object obj = null;
        int    result;

        try
        {
            obj = ToLua.ToObject(L, 1);
            AvatarBase avatarBase = (AvatarBase)obj;
            int        showAction = avatarBase.showAction;
            LuaDLL.lua_pushinteger(L, showAction);
            result = 1;
        }
        catch (Exception ex)
        {
            result = LuaDLL.toluaL_exception(L, ex, (obj != null) ? ex.Message : "attempt to index showAction on a nil value");
        }
        return(result);
    }
Ejemplo n.º 7
0
    public void CreateView(Vector3 pos)
    {
        avatar = AvatarLoader.Instance.Load <AvatarBase>(properties.name);
        avatar.fightDistance = Mathf.Abs(pos.x) - Random.Range(0.0f, 1.0f);
        if (avatar.fightDistance < 0)
        {
            avatar.fightDistance = Random.Range(0.1f, 0.3f);
        }
        avatar.id            = id;
        avatar.GameId        = properties.id;
        pos.z                = pos.y;
        avatar.tran.position = pos;

        //Init skillsqence.
        for (int i = 0; i < skillList.Count; i++)
        {
            avatar.skillSequence.AddSkill(skillList[i]);
        }
    }
Ejemplo n.º 8
0
    private static int SetAvatar(IntPtr L)
    {
        int result;

        try
        {
            ToLua.CheckArgsCount(L, 4);
            AvatarBase avatarBase = (AvatarBase)ToLua.CheckObject(L, 1, typeof(AvatarBase));
            GameObject go         = (GameObject)ToLua.CheckUnityObject(L, 2, typeof(GameObject));
            bool       click      = LuaDLL.luaL_checkboolean(L, 3);
            bool       rotate     = LuaDLL.luaL_checkboolean(L, 4);
            avatarBase.SetAvatar(go, click, rotate);
            result = 0;
        }
        catch (Exception e)
        {
            result = LuaDLL.toluaL_exception(L, e, null);
        }
        return(result);
    }