Exemple #1
0
    void Awake()
    {
        if (key.Length == 0)
        {
            LogSys.LogWarning("key is empty");
            return;
        }
        string str = "";

        if (FromLua == false || !sluaAux.luaSvrManager.getInstance().IsLoaded)
        {
            str = GameText.GetStr(key);
        }
        else
        {
            SLua.LuaState ls = sluaAux.luaSvrManager.getInstance().GetLuaState();
            if (ls != null)
            {
                SLua.LuaTable tb = ls.getTable("LuaText");
                if (tb[key] == null)
                {
                    str = GameText.GetStr(key);
                }
                else
                {
                    str = tb[key].ToString();
                }
            }
        }
        gameObject.GetComponent <UILabel>().text = UtilTools.Wrap(str);
    }
Exemple #2
0
 public void FireUnitEvent(SLua.LuaTable eventList)
 {
     if (eventList != null)
     {
         for (int i = 1; i <= eventList.length(); i++)
         {
             uiEvent?.FireUIEvent(eventList[i].ToString());
         }
     }
 }
Exemple #3
0
 static public int getv_s(IntPtr l)
 {
     try{
         SLua.LuaTable ret = HelloWorld.getv();
         pushValue(l, ret);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
Exemple #4
0
    public void InitEmptyWord(SLua.LuaTable emptyWordTable)
    {
        emptyWordMap.Clear();

        for (int i = 1; i <= emptyWordTable.length(); i++)
        {
            var word = emptyWordTable[i].ToString();
            if (word.Length == 1)
            {
                emptyWordMap.Add(word[0], 1);
            }
        }
    }
Exemple #5
0
 public static void InitBundleConfig(SLua.LuaTable luaConfig)
 {
     _allAsyncResBundleConfig.Clear();
     if (_allAsyncResDict.Count == 0)
     {
         return;
     }
     if (luaConfig == null)
     {
         return;
     }
     _allAsyncResBundleConfig = luaConfig.ToDictionary<string, string>();
 }
Exemple #6
0
    private void BindKey_Internal(string key, Func <object, bool> activeFunc, SLua.LuaTable parentKeyList = null, SLua.LuaTable filterList = null)
    {
        if (string.IsNullOrEmpty(key))
        {
            return;
        }

        RedPointData pointData = null;

        if (_redPointDataMap.ContainsKey(key))
        {
            pointData = _redPointDataMap[key];
        }
        else
        {
            pointData               = new RedPointData();
            pointData.key           = key;
            pointData.result        = false;
            pointData.filterMap     = new Dictionary <string, int>();
            pointData.childKeyList  = new List <string>();
            pointData.parentKeyList = new List <string>();
            _redPointDataMap.Add(key, pointData);
        }

        pointData.checkActiveFunc = activeFunc;
        if (filterList != null)
        {
            pointData.filterMap.Clear();
            for (int i = 0; i < filterList.length(); i++)
            {
                pointData.filterMap.Add(filterList[i + 1].ToString(), 1);
            }
        }
        if (parentKeyList != null)
        {
            pointData.parentKeyList.Clear();
            for (int i = 0; i < parentKeyList.length(); i++)
            {
                var parentKey = parentKeyList[i + 1].ToString();
                if (string.IsNullOrEmpty(parentKey))
                {
                    continue;
                }

                pointData.parentKeyList.Add(parentKey);
                BindChildKey(parentKey, key);
            }
        }
    }
Exemple #7
0
    public void Init(SLua.LuaTable forbidWordTable)
    {
        forbidTree.Clear();

        var forbidWordDic = forbidWordTable.ToDictionary <string, string>();

        foreach (KeyValuePair <string, string> word in forbidWordDic)
        {
            var wordCharArray = RevisionWord(word.Value.Trim()).ToCharArray();
            if (wordCharArray.Length <= 0)
            {
                continue;
            }

            ForbidTreeNode rootNode;
            if (forbidTree.ContainsKey(wordCharArray[0]))
            {
                rootNode = forbidTree[wordCharArray[0]];
            }
            else
            {
                rootNode = new ForbidTreeNode();
                forbidTree[wordCharArray[0]] = rootNode;
            }

            for (int i = 1; i < wordCharArray.Length; i++)
            {
                if (rootNode.nextForbidNodes != null && rootNode.nextForbidNodes.ContainsKey(wordCharArray[i]))
                {
                    rootNode = rootNode.nextForbidNodes[wordCharArray[i]];
                }
                else
                {
                    if (rootNode.nextForbidNodes == null)
                    {
                        rootNode.nextForbidNodes = new Dictionary <char, ForbidTreeNode>();
                    }

                    var nextNode = new ForbidTreeNode();
                    rootNode.nextForbidNodes[wordCharArray[i]] = nextNode;
                    rootNode = nextNode;
                }
            }
            rootNode.wholeForbidWord = word.Value;
        }
    }
Exemple #8
0
        public static BuffInterface CreateBuff(SLua.LuaTable table)
        {
            Buff _buff = new Buff
            {
                //properties
                m_sName        = (string)table["Name"],
                m_sDesc        = (string)table["Description"],
                m_nMaxStackNum = System.Convert.ToInt32(table["MaxStackNum"]),
                m_bStackable   = System.Convert.ToBoolean(table["Stackable"]),
                m_fDuration    = System.Convert.ToSingle(table["Duration"])
            };

            //bonuses
            SLua.LuaTable _bonus = (SLua.LuaTable)table["Bonus"];
            _buff.m_Bonuses = new DAttributeBonus[_bonus.length()];
            for (int i = 1; i <= _bonus.length(); i++)
            {
                SLua.LuaTable _oneBonus = (SLua.LuaTable)_bonus[i];
                _buff.m_Bonuses[i - 1] = new DAttributeBonus(
                    (AttrType)System.Convert.ToInt32(_oneBonus[1]),
                    System.Convert.ToSingle(_oneBonus[3]),
                    System.Convert.ToBoolean(_oneBonus[2])
                    );
            }

            //functions
            _buff.OnAttach  += _CastFunc(table["OnAttach"]);
            _buff.OnDetach  += _CastFunc(table["OnDetach"]);
            _buff.OnUpdate  += _CastFunc(table["OnUpdate"]);
            _buff.OnDamaged += _CastFunc(table["OnDamaged"]);
            _buff.OnTimeUp  += _CastFunc(table["OnTimeUp"]);

            _buff.m_Interface = new BuffInterface(_buff);

            return(_buff.m_Interface);
        }
Exemple #9
0
 public void Init(SLua.LuaTable forbidWordTable, SLua.LuaTable emptyWordTable)
 {
     InitEmptyWord(emptyWordTable);
     Init(forbidWordTable);
 }
Exemple #10
0
    public void InitFromLuaFile()
    {
        SLua.LuaTable _table;
        //Script prefix path: Assets/Scripts/Lua/
        //read file
        _table = (SLua.LuaTable)SLua.LuaSvr.getInstance().doFile("Items/" + m_LuaScript);

        //onuse function
        SLua.LuaFunction _func = (SLua.LuaFunction)SLua.LuaSvr.mainState["OnUse"];
        if (_func != null)
        {
            m_UsageDelegate += _func.cast <ItemUsage>();
        }

        //load all the properties
        _table = (SLua.LuaTable)SLua.LuaSvr.mainState["properties"];

        //load mesh
        m_Prefab = (string)_table["Mesh"];
        //GameObject _tmp = Resources.Load<GameObject>("Prefabs/"+m_Prefab);
        GameObject _tmp = Resources.Load <GameObject>("Meshes/" + m_Prefab);

        _tmp = Instantiate(_tmp);
        gameObject.AddComponent <MeshFilter>();
        gameObject.AddComponent <MeshRenderer>();
        gameObject.GetComponent <MeshFilter>().mesh   = _tmp.GetComponent <MeshFilter>().mesh;
        gameObject.GetComponent <Renderer>().material = _tmp.GetComponent <Renderer>().material;
        gameObject.transform.localScale = _tmp.transform.localScale;
        GameObject.Destroy(_tmp);

        //attributes
        m_ItemName    = (string)_table["Name"];
        m_Description = (string)_table["Description"];

        m_Type = (ItemType)System.Convert.ToInt32(_table["Type"]);
        switch (m_Type)
        {
        case ItemType.ITEM_PRIMARY:
            m_ShotType    = (ShotType)System.Convert.ToInt32(_table["ShotType"]);
            m_AttackSpeed = System.Convert.ToSingle(_table["AttackSpeed"]);
            m_EnergyCost  = System.Convert.ToSingle(_table["EnergyCost"]);
            m_Damage      = System.Convert.ToSingle(_table["FirePower"]);
            break;

        case ItemType.ITEM_MELEE:
            m_Damage      = System.Convert.ToSingle(_table["Damage"]);
            m_AttackSpeed = System.Convert.ToSingle(_table["AttackSpeed"]);
            break;

        case ItemType.ITEM_PARTS:
            m_Damage     = System.Convert.ToSingle(_table["Damage"]);
            m_Projectile = (string)_table["Ammo"];
            break;

        case ItemType.ITEM_ARMOR:
            m_Armor = System.Convert.ToSingle(_table["Armor"]);
            break;

        default:
            break;
        }
        m_Weight = System.Convert.ToSingle(_table["Weight"]);

        SLua.LuaTable _bonus = (SLua.LuaTable)_table["Bonus"];
        m_BonusList = new DAttributeBonus[_bonus.length()];
        for (int i = 1; i <= _bonus.length(); i++)
        {
            SLua.LuaTable _oneBonus = (SLua.LuaTable)_bonus[i];
            m_BonusList[i - 1] = new DAttributeBonus(
                (AttrType)System.Convert.ToInt32(_oneBonus[1]),
                System.Convert.ToSingle(_oneBonus[3]),
                System.Convert.ToBoolean(_oneBonus[2])
                );
        }

        m_bIfLoaded = true;
    }
Exemple #11
0
 public void FireTowerEvent(SLua.LuaTable eventList)
 {
     towerContainer.tower?.FireUnitEvent(eventList);
 }
Exemple #12
0
 public static void BindKey(string key, Func <object, bool> activeFunc, SLua.LuaTable parentKeyList = null, SLua.LuaTable filterList = null)
 {
     RedPointManager.INSTANCE.BindKey_Internal(key, activeFunc, parentKeyList, filterList);
 }
Exemple #13
0
 public Enumerator(LuaTable table)
 {
     t = table;
     Reset();
 }