void LoadDataPlayerPriority_Level(GameObject player)
        {
            Component[] components = player.GetComponents <LevelableComponent>();

            List <TablePlayerLevel> levels = Query <TablePlayerLevel>("SELECT * FROM " + nameof(TablePlayerLevel) + " WHERE owner=?", player.name);

            if (levels == null || levels.Count < 1)
            {
                return;
            }

            foreach (TablePlayerLevel row in levels)
            {
                foreach (Component component in components)
                {
                    if (component is LevelableComponent)
                    {
                        LevelableComponent manager = (LevelableComponent)component;

                        if (manager.GetType().ToString() == row.name)
                        {
                            manager.level = row.level;
                        }
                    }
                }
            }
        }
示例#2
0
        void SaveDataPlayer_Level(GameObject player, bool isNew)
        {
            // you should delete all data of this player first, to prevent duplicates
            DeleteDataPlayer_Level(player.name);

            Component[] components = player.GetComponents <LevelableComponent>();

            foreach (Component component in components)
            {
                if (component is LevelableComponent)
                {
                    LevelableComponent lc = (LevelableComponent)component;

                    InsertOrReplace(new TablePlayerLevel {
                        owner = player.name,
                        name  = lc.GetType().ToString(),
                        level = lc.level
                    });
                }
            }
        }