Exemple #1
0
 static int GetShape(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         int             arg0 = (int)LuaDLL.luaL_checknumber(L, 1);
         Character.Shape o    = Character.GetShape(arg0);
         ToLua.PushObject(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Exemple #2
0
    static int get_currShape(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            Character       obj = (Character)o;
            Character.Shape ret = obj.currShape;
            ToLua.PushObject(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index currShape on a nil value" : e.Message));
        }
    }
Exemple #3
0
    // 设置形象
    public void SetShape(Character.Shape shape)
    {
        Init();

        shape.actionDirNum = new short[6];

        AnimatorOverrideController overrideController = new AnimatorOverrideController();

        overrideController.runtimeAnimatorController = _Animator.runtimeAnimatorController;

        // 先看是否有此动作,然后加载
        for (int i = 0; i < 8; i++)
        {
            for (int j = 0; j < 6; j++)
            {
                // 枚举转成字符串,当做动作名
                string actionName = ((ACTION)j).ToString();

                // 读取动画文件,并累计动作数量
                if ((shape.action[j] & (1 << i)) != 0)
                {
                    AnimationClip clip = ResourceManager.LoadCharactorAnime(shape.shape + "_" + actionName + "_" + i, shape.shape, shape.abname);
                    if (clip == null)
                    {
                        continue;
                    }

                    clip.name = actionName + "_" + i;
                    overrideController[actionName + "_" + i] = clip;
                    shape.actionDirNum[j] += 1;
                }
            }
        }

        _Animator.runtimeAnimatorController = overrideController;

        // 应用染色
        _Animator.GetComponent <SpriteRenderer>().color = shape.color;
    }