Esempio n. 1
0
        // Save the current map to the database.  If no mapID is provided,
        // a new id is created.  Otherwise, it saves over the existing ID.
        void SaveMapToDB(string mapId)
        {
            if (mapId == null)
            {
                mapId = CommonData.currentUser.GetUniqueKey();
            }
            string path = CommonData.DBMapTablePath + mapId;
            DBStruct <LevelMap> dbLevel = new DBStruct <LevelMap>(path, CommonData.app);

            LevelMap currentLevel = CommonData.gameWorld.worldMap;

            currentLevel.SetProperties(dialogComponent.MapName.text,
                                       mapId, CommonData.currentUser.data.id, path);
            CommonData.gameWorld.OnSave();

            dbLevel.Initialize(currentLevel);
            dbLevel.PushData();

            Firebase.Analytics.FirebaseAnalytics.LogEvent(StringConstants.AnalyticsEventMapCreated,
                                                          StringConstants.AnalyticsParamMapId, CommonData.gameWorld.worldMap.mapId);

            if (Social.localUser.authenticated)
            {
                Social.ReportProgress(GPGSIds.achievement_map_maker, 100.0f, (bool success) => {
                    Debug.Log("Edit a game achiement unlocked. Sucess: " + success);
                });
            }

            CommonData.currentUser.data.AddMap(currentLevel.name, currentLevel.mapId);
            CommonData.currentUser.PushData();
            manager.PopState();
        }
Esempio n. 2
0
        // Save the current map to the database.  If no mapID is provided,
        // a new id is created.  Otherwise, it saves over the existing ID.
        void SaveMapToDB(string mapId)
        {
            if (mapId == null)
            {
                mapId = CommonData.currentUser.GetUniqueKey();
            }
            string path = CommonData.DBMapTablePath + mapId;
            DBStruct <LevelMap> dbLevel = new DBStruct <LevelMap>(path, CommonData.app);

            LevelMap currentLevel = CommonData.gameWorld.worldMap;

            currentLevel.SetProperties(dialogComponent.MapName.text,
                                       mapId, CommonData.currentUser.data.id, path);
            CommonData.gameWorld.OnSave();

            dbLevel.Initialize(currentLevel);
            dbLevel.PushData();

            Firebase.Analytics.FirebaseAnalytics.LogEvent(StringConstants.AnalyticsEventMapCreated,
                                                          StringConstants.AnalyticsParamMapId, CommonData.gameWorld.worldMap.mapId);

            CommonData.currentUser.data.AddMap(currentLevel.name, currentLevel.mapId);
            CommonData.currentUser.PushData();
            manager.PopState();
        }
Esempio n. 3
0
    private bool LoadMissionScriptFile()
    {
        try
        {
            //UnityEngine.Object MissionFileObj = Resources.Load("Private/Script");

            //if (MissionFileObj == null)
            //{
            //    LogManager.LogError("\r\n----------------------------------------------------\r\n");
            //    LogManager.LogError("Load Resources Script.txt 出错。");
            //    LogManager.LogError("\r\n----------------------------------------------------\r\n");
            //    return false;
            //}

            //TextAsset MissionFileAsset = (TextAsset)MissionFileObj;

            string   scriptData   = DBStruct.GetResources("Private/Script");
            string[] MissionFiles = scriptData.Split(new string[1] {
                "\r\n"
            }, StringSplitOptions.None);

            for (int i = 0; i < MissionFiles.Length; i++)
            {
                IndexForLog++;
                MissionFiles[i].Trim();
                if (MissionFiles[i].Equals("") || MissionFiles[i].StartsWith(";"))
                {
                    continue;
                }
                else
                {
                    int npos = MissionFiles[i].IndexOf("=");
                    if (npos == -1)
                    {
                        continue;
                    }
                    int    ID = Convert.ToInt32(MissionFiles[i].Substring(0, npos).Trim());
                    string MissionFilePath = MissionFiles[i].Substring(npos + 1).Trim();
                    MissionFilePath = "Private" + MissionFilePath.Replace(".lua", "");
                    MissionFilePath = MissionFilePath.Replace("\\", "/");
                    m_mapQuestFile.Add(ID, MissionFilePath);
                }
            }

            return(true);
        }
        catch (Exception ex)
        {
            LogManager.LogError("--------------------出错行ID为:" + IndexForLog + " ,第二次出现该ID。--------------------");
            LogManager.LogError(ex.ToString());
            return(false);
        }
    }
Esempio n. 4
0
        private void temp_Cal(object sender, RoutedEventArgs e)
        {
            M2BDbSetting dbset = new M2BDbSetting();
            DBStruct     tmp   = new DBStruct();

            tmp.DBID    = 0x8d;
            tmp.DBValue = (uint)water_temp.Value;
            dbset._DBGroup.Add(tmp);
            byte[] sendcmd = dbset.EnCode();
            lock (this)
            {
                comunication.Getinstance().AddtoSend(sendcmd, (byte)sendcmd.Length);
            }
            MessageBox.Show("Set Temp Finished");
        }
Esempio n. 5
0
        private void Cal_Button_Click(object sender, RoutedEventArgs e)
        {
            M2BDbSetting dbset = new M2BDbSetting();
            DBStruct     tmp   = new DBStruct();

            tmp.DBID    = _CalPartNo;
            tmp.DBValue = (uint)CalInport1.Value;
            dbset._DBGroup.Add(tmp);
            byte[] sendcmd = dbset.EnCode();
            lock (this)
            {
                comunication.Getinstance().AddtoSend(sendcmd, (byte)sendcmd.Length);
            }
            //MessageBox.Show("SET DB");
        }
Esempio n. 6
0
        // Save the current map to the database.  If no mapID is provided,
        // a new id is created.  Otherwise, it saves over the existing ID.
        void SetMapToShared()
        {
            LevelMap currentLevel = CommonData.gameWorld.worldMap;

            if (currentLevel.isShared == true)
            {
                // Map is already shared.
                return;
            }

            currentLevel.isShared = true;
            DBStruct <LevelMap> dbLevel = new DBStruct <LevelMap>(
                CommonData.DBMapTablePath + currentLevel.mapId, CommonData.app);

            dbLevel.Initialize(currentLevel);
            dbLevel.PushData();
        }
Esempio n. 7
0
        // Save the current map to the database.  If no mapID is provided,
        // a new id is created.  Otherwise, it saves over the existing ID.
        void SaveMapToDB()
        {
            string path = CommonData.DBBonusMapTablePath + mapId;
            DBStruct <LevelMap> dbLevel = new DBStruct <LevelMap>(path, CommonData.app);

            LevelMap currentLevel = CommonData.gameWorld.worldMap;

            currentLevel.SetProperties(mapName, mapId, CommonData.currentUser.data.id, path);
            CommonData.gameWorld.OnSave();

            dbLevel.Initialize(currentLevel);
            dbLevel.PushData();

            CommonData.currentUser.data.AddMap(currentLevel.name, currentLevel.mapId);
            CommonData.currentUser.PushData();
            manager.PopState();
        }
Esempio n. 8
0
 public void ReadStruct()
 {
     OnlineDataBlock = (DBStruct)plc.ReadStruct(typeof(DBStruct), ConfigParameters.DATA_BLOCK_NUMBER);
 }
    public bool OpenScript(string filename)
    {
        try
        {
            if (filename == string.Empty)
            {
                LogManager.LogError("--------------------要读取的名为: " + filename + " 的Lua脚本为空。--------------------");
                return(false);
            }

//             UnityEngine.Object FileObject = Resources.Load(filename);
//
//             if (FileObject == null)
//             {
//                 LogManager.LogError("\r\n----------------------------------------------------\r\n");
//                 LogManager.LogError("Load Resources名为: " + filename + " 的Lua脚本为空。");
//                 LogManager.LogError("\r\n----------------------------------------------------\r\n");
//                 return false;
//             }
//
            //             TextAsset asset = (TextAsset)FileObject;
            // 对文件名特殊处理 [3/16/2012 Ivan]
            filename = filename.Replace(".lua", ".txt");
            filename = filename.Replace("\\", "/");
            string fileContent = DBStruct.GetResources(filename);

            string[] strsTemp = fileContent.Split(new string[1] {
                "\r\n"
            }, StringSplitOptions.None);

            for (int i = 0; i < strsTemp.Length; i++)
            {
                strsTemp[i] = strsTemp[i].Trim();
                if (!strsTemp[i].Equals(""))
                {
                    if (!strsTemp[i].StartsWith("--"))
                    {
                        if (i >= 1)
                        {
                            if (!strsTemp[i].StartsWith("x"))
                            {
                                int j = 1;
                                while (strsTemp[i - j].Equals(""))
                                {
                                    j++;
                                }
                                strsTemp[i - j] += strsTemp[i];
                                strsTemp[i]      = string.Empty;
                            }
                        }
                        else
                        {
                            LogManager.LogError("--------------------脚本第一个属性出错,不是以x开头!--------------------");
                            return(false);
                        }
                    }
                }
            }

            ListTemp.Clear();
            for (int i = 0; i < strsTemp.Length; i++)
            {
                if (!strsTemp[i].Equals(""))
                {
                    if (!strsTemp[i].StartsWith("--"))
                    {
                        ListTemp.Add(strsTemp[i]);
                    }
                }
            }

            ScriptInfoMap.Clear();
            if (GetScriptInfoMap(ref ScriptInfoMap, ListTemp))
            {
                if (!ParseScript(ScriptInfoMap))
                {
                    LogManager.LogError("--------------------解析脚本出错。出错脚本名为:" + filename + " 。--------------------");
                    return(false);
                }
            }
            else
            {
                LogManager.LogError("--------------------从ScriptInfoMap中获取脚本信息出错。出错脚本名为:" + filename + " 。--------------------");
                return(false);
            }

            return(true);
        }
        catch (Exception ex)
        {
            CDataBaseSystem.StrError += "--------------------读取名为: " + filename + " 的Lua脚本出错。--------------------";
            CDataBaseSystem.StrError += ex.ToString();
            throw new Exception(CDataBaseSystem.StrError);
        }
    }