示例#1
0
文件: Unit.cs 项目: harryheslin/Novus
        public UnitDB ConvertToDB()
        {
            List <ClassDB> classes = new List <ClassDB>();

            foreach (Class value in Tutorials)
            {
                classes.Add(value.ConvertToDB());
            }

            foreach (Class value in Lectures)
            {
                classes.Add(value.ConvertToDB());
            }

            List <AnnouncementDB> announcements = new List <AnnouncementDB>();

            foreach (Announcement value in StaffAnnouncements)
            {
                announcements.Add(value.ConvertToDB());
            }

            List <AssesmentDB> assesments = new List <AssesmentDB>();

            foreach (Assesment value in Assesments)
            {
                assesments.Add(value.ConvertToDB());
            }

            List <ResourcesDB> resources = new List <ResourcesDB>();

            foreach (Resources value in UnitResources)
            {
                resources.Add(value.ConvertToDB());
            }

            string information = "";

            foreach (Information value in Information)
            {
                information += value.Line + "|";
            }

            UnitDB returnValue = new UnitDB
            {
                UnitID             = this.UnitID,
                SemesterID         = this.SemesterID,
                Code               = this.Code,
                Colour             = this.Colour,
                Name               = this.Name,
                Information        = information,
                Classes            = classes,
                StaffAnnouncements = announcements,
                Assesments         = assesments,
                UnitResources      = resources,
                StudentID          = this.StudentID
            };

            return(returnValue);
        }
示例#2
0
    public static UnitDB LoadUnitBlueprintPreview(string LocalPath)
    {
        if (LoadedUnitBPPreviews.ContainsKey(LocalPath))
        {
            return(LoadedUnitBPPreviews[LocalPath]);
        }


        byte[] Bytes = LoadBytes(UnitsScd, LocalPath);
        if (Bytes == null || Bytes.Length == 0)
        {
            Debug.LogWarning("Unit does not exits: " + LocalPath);
            return(new UnitDB(LocalPath));
        }
        string BluePrintString = System.Text.Encoding.UTF8.GetString(Bytes);

        if (BluePrintString.Length == 0)
        {
            Debug.LogWarning("Loaded blueprint is empty");
            return(new UnitDB(LocalPath));
        }

        BluePrintString = BluePrintString.Replace("UnitBlueprint {", "UnitBlueprint = {");


        //Fix LUA
        string[] SplitedBlueprint   = BluePrintString.Split("\n".ToCharArray());
        string   NewBlueprintString = "";

        for (int i = 0; i < SplitedBlueprint.Length; i++)
        {
            if (SplitedBlueprint[i].Length > 0 && !SplitedBlueprint[i].Contains("#"))
            {
                NewBlueprintString += SplitedBlueprint[i] + "\n";
            }
        }
        BluePrintString = NewBlueprintString;

        Lua BP = new Lua();

        BP.LoadCLRPackage();

        try
        {
            BP.DoString(MapLuaParser.Current.SaveLuaHeader.text + BluePrintString);
        }
        catch (NLua.Exceptions.LuaException e)
        {
            Debug.LogWarning(LuaParser.Read.FormatException(e) + "\n" + LocalPath);
            return(new UnitDB(LocalPath));
        }
        UnitDB ToReturn = new UnitDB(BP, LocalPath);

        LoadedUnitBPPreviews.Add(LocalPath, ToReturn);

        return(ToReturn);
    }
示例#3
0
        public UnitListController()
        {
            Unit        = UnitDB.loadAll();
            visibleUnit = new ObservableCollection <Unit>(Unit); //this list we will modify later

            foreach (Unit s in Unit)
            {
                s.setClassTime(ClassTimeDB.loadByState(s.UnitCode));
            }
        }
示例#4
0
 // Start is called before the first frame update
 protected virtual void Start()
 {
     spell_db = (SpellDB)Resources.Load("SpellDatabase");
     unit_db  = (UnitDB)Resources.Load("UnitDatabase");
     npc_db   = (NPCDB)Resources.Load("NPCDatabase");
     npc_list = new List <NPC>();
     SpawnRaid();
     AddNewNPCs(raid_manager.unit_list);
     InitThreatTables();
     encountertime = 0;
 }
 public void InitArgs(string TableName = "SerialPort")
 {
     CompactDB             = R.CompactDB;
     CompactDB.TargetTable = TableName;
     base.PortName         = CompactDB.FetchValue("COM", true, "0");
     base.Parity           = (Parity)CompactDB.FetchIntValue("Parity");
     base.StopBits         = (StopBits)CompactDB.FetchIntValue("StopBits");
     base.BaudRate         = CompactDB.FetchIntValue("BaudRate");
     base.DataBits         = CompactDB.FetchIntValue("DataBits");
     base.BufferSize       = 128;
     CompactDB.TargetTable = CompactDB.DefaultTable;
 }
示例#6
0
        public void TestUnitDB()
        {
            string data = TestContext.RootPath + "Resources/MtUnit.txt";

            data = File.ReadAllText(data);
            Assert.NotZero(data.Length);

            UnitDB.Init(data);
            Assert.NotZero(UnitDB.Instance.Count);
            Assert.True(UnitDB.Instance.ContainsKey("[Character]akizuki_ritsukoA"));
            Assert.AreEqual(UnitType.Vi, UnitDB.Instance["[Character]akizuki_ritsukoA"].UnitType);
        }
示例#7
0
        // Constructor function to load the list of teachers
        public StaffListController()
        {
            // Read all the information in the teacher table
            Staff        = StaffDB.loadAll();
            visibleStaff = new ObservableCollection <Staff>(Staff); //this list we will modify later

            // Read qa information for every teacher
            foreach (Staff c in Staff)
            {
                c.setConsultation(consultationDB.loadByID(c.StaffID));
                c.setStaffUnit(UnitDB.loadByID(c.StaffID));
            }
        }
 protected virtual void btn_Search_Click(object sender, EventArgs e)
 {
     ThisDB = R.CompactDB;
     if (rbtn_Log.Checked)
     {
         QueryLogs();
     }
     if (rbtn_NGReporting.Checked)
     {
         QueryOKNGPercent();
     }
     if (rbtn_NGDetails.Checked)
     {
         QueryNGStatus();
     }
 }
示例#9
0
    // Runs second
    private bool _testAddUnitToBoard()
    {
        bool _passed = true;

        Dictionary <string, object> prm = new Dictionary <string, object>();

        prm.Add("unitData", UnitDB.UNCR_Soldier());
        prm.Add("x", 2);
        prm.Add("y", 3);

        string result = testBoardSpace.ToString();

        if (!result.Equals(DTestBoardGeneration.addedSoldierTo_x2y3_4X4))
        {
            _passed = false;
            Debug.Log("add unit to board failed it's test");
        }

        return(_passed);
    }
 public virtual void Run(ToolBlockPowerSuite toolBlockPowerSuite, bool Lockable = false, params object[] Inputs)
 {
     if (!Lockable)
     {
         toolBlockPowerSuite.Run(RanToolBlock, Inputs);
         App.nTodayImageCount++;
         new Thread((ThreadStart) delegate
         {
             UnitDB compactDB3 = base.CompactDB;
             string manufatureTotalNumRecordTable_PerDay2 = App.ManufatureTotalNumRecordTable_PerDay;
             DateTime now2 = DateTime.Now;
             compactDB3.Write(manufatureTotalNumRecordTable_PerDay2, now2.ToString("yyyy-MM-dd"), App.nTodayImageCount.ToString());
             UnitDB compactDB4 = base.CompactDB;
             string nGNumRecordTable_PerDay2 = App.NGNumRecordTable_PerDay;
             now2 = DateTime.Now;
             compactDB4.Write(nGNumRecordTable_PerDay2, now2.ToString("yyyy-MM-dd"), App.nNGNum.ToString());
             DoRefreshManufatureIndicators();
         }).Start();
     }
     else
     {
         lock (LockSoftwareTrigger)
         {
             toolBlockPowerSuite.Run(RanToolBlock, Inputs);
             App.nTodayImageCount++;
             new Thread((ThreadStart) delegate
             {
                 UnitDB compactDB = base.CompactDB;
                 string manufatureTotalNumRecordTable_PerDay = App.ManufatureTotalNumRecordTable_PerDay;
                 DateTime now = DateTime.Now;
                 compactDB.Write(manufatureTotalNumRecordTable_PerDay, now.ToString("yyyy-MM-dd"), App.nTodayImageCount.ToString());
                 UnitDB compactDB2 = base.CompactDB;
                 string nGNumRecordTable_PerDay = App.NGNumRecordTable_PerDay;
                 now = DateTime.Now;
                 compactDB2.Write(nGNumRecordTable_PerDay, now.ToString("yyyy-MM-dd"), App.nNGNum.ToString());
                 DoRefreshManufatureIndicators();
             }).Start();
         }
     }
 }
示例#11
0
    void Awake()
    {
        instance = this;

        PerkManager perkManager = (PerkManager)FindObjectOfType(typeof(PerkManager));

        if (perkManager != null)
        {
            perkManager.Init();
        }

        AbilityManagerUnit abManagerUnit = (AbilityManagerUnit)FindObjectOfType(typeof(AbilityManagerUnit));

        if (abManagerUnit != null)
        {
            abManagerUnit.Init();
        }


        availableUnitList = new List <Unit>(UnitDB.Load());             //load the unit from DB, you manually assign this if you want

        //since we are loading from DB, we dont want the AI unit, which started from 6 (so we remove them)
        while (availableUnitList.Count > 9)
        {
            availableUnitList.RemoveAt(availableUnitList.Count - 1);
        }

        //if this there isn't any save
        if (!PlayerPrefs.HasKey("TBTK_Demo"))
        {
            //for demo purpose, we are using perk currency as the universal currency
            //so we set the perk currency to our starting value and let PerkManager keep track of it
            PerkManager.SetPerkCurrency(startingCurrency);

            PlayerPrefs.SetInt("TBTK_Demo", 1);
        }
        else
        {
            //check with data to see if the scene is loaded from a battle
            if (TBData.BattleEndDataExist())
            {
                List <TBDataUnit> dataList = TBData.GetEndData(0);              //get the data, the ID is zero, since we start the battle with 0
                //note that the faction in the battle scene is configured to load data from 0 too

                if (dataList != null)                   //add the unit based on the dataList
                {
                    for (int i = 0; i < dataList.Count; i++)
                    {
                        selectedUnitList.Add(dataList[i].unit);
                    }
                }

                for (int i = 0; i < selectedUnitList.Count; i++)                        //fill up the availableUnitMapList (for saving)
                {
                    bool match = false;
                    for (int n = 0; n < availableUnitList.Count; n++)                           //find the corresponding unit in availableList and add the index to selectedUnitMapList
                    {
                        if (selectedUnitList[i] == availableUnitList[n])
                        {
                            selectedUnitMapList.Add(n);
                            match = true;
                            break;
                        }
                    }
                    //if there's no match in availableUnitList, unit no longer available in game, remove it from selected list
                    if (!match)
                    {
                        selectedUnitList.RemoveAt(i);
                        i -= 1;
                    }
                }

                _SaveLoadOut();
            }
            else                //if we are not loading the scene from a battle, load the selectedUnitList from previous save in stead of getting it from data
            {
                _LoadLoadOut();
            }
        }
    }
        private void QueryLogs()
        {
            ThisDB = R.LogDB;
            string text = null;
            bool   flag = false;

            if (dateTimePicker1.Text.Equals(dateTimePicker2.Text))
            {
                flag = true;
            }
            DateTime value;

            if (dateTimePicker2.Value < dateTimePicker2.Value)
            {
                dotNetLab.Tipper.Error = "第二个日期控件的日期必须大于或者等于前一个日期控件的日期。";
            }
            else if (flag)
            {
                value = dateTimePicker1.Value;
                string arg = value.ToString("yyyy-MM-dd");
                value = dateTimePicker1.Value;
                object arg2 = value.Year;
                value = dateTimePicker1.Value;
                text  = string.Format("_{0}_{1}", arg2, value.Month);
                dataGridView1.DataSource = ThisDB.ProvideTable(string.Format("SELECT Fire_Time as 触发时间,Message as 基本信息 FROM {0} where Fire_Time like '{1}%';", text, arg), dotNetLab.Data.DBOperator.OPERATOR_QUERY_TABLE);
            }
            else
            {
                value = dateTimePicker1.Value;
                string arg3 = value.ToString("yyyy-MM-dd");
                value = dateTimePicker2.Value;
                string arg4 = value.AddDays(1.0).ToString("yyyy-MM-dd");
                ThisDB.GetAllTableNames();
                DataTable dataTable = new DataTable();
                dataTable.Columns.Add();
                dataTable.Columns[0].ColumnName = "触发时间";
                dataTable.Columns.Add();
                dataTable.Columns[1].ColumnName = "基本信息";
                int num = 0;
                for (int i = 0; i < ThisDB.AllTableNames.Count; i++)
                {
                    if (!ThisDB.DefaultTable.Equals(ThisDB.AllTableNames[i]))
                    {
                        text = ThisDB.AllTableNames[i];
                        DataTable dataTable2 = ThisDB.ProvideTable(string.Format("SELECT Fire_Time as 触发时间,Message  as 基本信息 FROM {0} where Fire_Time >='{1}' and Fire_Time <'{2}';", text, arg3, arg4), dotNetLab.Data.DBOperator.OPERATOR_QUERY_TABLE);
                        if (dataTable2 != null && dataTable2.Rows.Count > 0)
                        {
                            for (int j = 0; j < dataTable2.Rows.Count; j++)
                            {
                                dataTable.Rows.Add();
                                for (int k = 0; k < dataTable2.Columns.Count; k++)
                                {
                                    dataTable.Rows[num][k] = dataTable2.Rows[j][k];
                                }
                                num++;
                            }
                        }
                    }
                }
                dataGridView1.DataSource = dataTable;
            }
        }
示例#13
0
        public void Setup()
        {
            string unitData = System.IO.File.ReadAllText("../../../Resources/MtUnit.txt");

            UnitDB.Init(unitData);
        }
        protected override void prepareData()
        {
            base.prepareData();
            string text = base.CompactDB.FetchValue(App.AutoCleanTime, true, "0");

            if (text == null)
            {
                base.CompactDB.Write(App.AutoCleanTime, "0");
            }
            string text2 = base.CompactDB.FetchValue(App.ApplyUserPriority, true, "0");

            if (text2 == null)
            {
                base.CompactDB.Write(App.ApplyUserPriority, "0");
            }
            string text3 = base.CompactDB.FetchValue(App.HideMainForm, true, "0");

            if (text3 == null)
            {
                base.CompactDB.Write(App.HideMainForm, "0");
            }
            string text4 = base.CompactDB.FetchValue(App.Contact, true, "0");

            if (text4 == null)
            {
                base.CompactDB.Write(App.Contact, " ");
            }
            string text5 = base.CompactDB.FetchValue(App.IncName, true, "0");

            if (text5 == null)
            {
                base.CompactDB.Write(App.IncName, " ");
            }
            PrepareCommunication();
            base.CompactDB.GetAllTableNames();
            int num = base.CompactDB.AllTableNames.IndexOf(App.ImageRecord);

            if (num == -1)
            {
                base.CompactDB.NewTable(App.ImageRecord, "图片路径 Text not null ,OKNG Text not null,图像生成日期 Text not null,描述 Text not null");
            }
            num = base.CompactDB.AllTableNames.IndexOf(App.ManufatureTotalNumRecordTable_PerDay);
            if (num == -1)
            {
                base.CompactDB.CopyKeyValueTable(App.ManufatureTotalNumRecordTable_PerDay, base.CompactDB.DefaultTable);
                base.CompactDB.ExecuteNonQuery("delete from " + App.ManufatureTotalNumRecordTable_PerDay, dotNetLab.Data.DBOperator.OPERATOR_TRUNCATE);
            }
            UnitDB   compactDB = base.CompactDB;
            DateTime now       = DateTime.Now;

            App.nTodayImageCount = compactDB.FetchIntValue(now.ToString("yyyy-MM-dd"), App.ManufatureTotalNumRecordTable_PerDay);
            num = base.CompactDB.AllTableNames.IndexOf(App.NGNumRecordTable_PerDay);
            if (num == -1)
            {
                base.CompactDB.CopyKeyValueTable(App.NGNumRecordTable_PerDay, base.CompactDB.DefaultTable);
                base.CompactDB.ExecuteNonQuery("delete from " + App.NGNumRecordTable_PerDay, dotNetLab.Data.DBOperator.OPERATOR_TRUNCATE);
            }
            UnitDB compactDB2 = base.CompactDB;

            now        = DateTime.Now;
            App.nNGNum = compactDB2.FetchIntValue(now.ToString("yyyy-MM-dd"), App.NGNumRecordTable_PerDay);
            num        = base.CompactDB.AllTableNames.IndexOf(App.StatisticNGOKPercentTable_PerDay);
            if (num == -1)
            {
                base.CompactDB.CopyKeyValueTable(App.StatisticNGOKPercentTable_PerDay, base.CompactDB.DefaultTable);
                base.CompactDB.ExecuteNonQuery("delete from " + App.StatisticNGOKPercentTable_PerDay, dotNetLab.Data.DBOperator.OPERATOR_TRUNCATE);
            }
        }
        protected void AutoSaveClearImage(Bitmap bmp, string Description, bool OKNG = false, string picturePath = "图片", UnitDB thisDB = null)
        {
            if (thisDB == null)
            {
                thisDB = base.CompactDB;
            }
            List <string> nameColumnValues = base.CompactDB.GetNameColumnValues(base.CompactDB.DefaultTable);

            if (!nameColumnValues.Contains("AutoClearTime"))
            {
                base.CompactDB.Write("AutoClearTime", "3");
            }
            if (!Directory.Exists(picturePath))
            {
                Directory.CreateDirectory(picturePath);
            }
            DateTime dateTime = DateTime.Now;
            string   text     = string.Format("{0}\\{1}", picturePath, dateTime.ToString("yyyy-MM-dd"));

            if (!Directory.Exists(text))
            {
                Directory.CreateDirectory(text);
            }
            string path = text;

            dateTime = DateTime.Now;
            string text2 = Path.Combine(path, dateTime.ToString("yyyy-MM-dd HH_mm_ss") + ".bmp");

            bmp.Save(text2);
            string text3 = null;

            text3 = ((!OKNG) ? "NG" : "OK");
            UnitDB unitDB      = thisDB;
            string imageRecord = App.ImageRecord;

            object[] obj = new object[4]
            {
                text2,
                text3,
                null,
                null
            };
            dateTime = DateTime.Now;
            obj[2]   = dateTime.ToString("yyyy-MM-dd HH:mm:ss");
            obj[3]   = Description;
            unitDB.NewRecord(imageRecord, string.Format("'{0}','{1}','{2}','{3}'", obj));
            int num = base.CompactDB.FetchIntValue("AutoClearTime");

            if (Directory.GetDirectories(picturePath).Length > num)
            {
                dateTime = DateTime.Now;
                dateTime = DateTime.Parse(dateTime.ToString("yyyy-MM-dd"));
                string path2 = dateTime.AddDays((double)(-num)).ToString("yyyy-MM-dd");
                if (Directory.Exists(Path.Combine(picturePath, path2)))
                {
                    string   text4 = Path.Combine(picturePath, path2);
                    string[] files = Directory.GetFiles(text4);
                    for (int i = 0; i < files.Length; i++)
                    {
                        File.Delete(files[i]);
                    }
                    Directory.Delete(text4);
                    base.CompactDB.RemoveRecord(App.ImageRecord, string.Format("图像生成日期 like '{0}%'", text4));
                }
            }
        }
 public RetriveDataForm()
 {
     InitializeComponent();
     ThisDB = R.LogDB;
 }
示例#17
0
 void Start()
 {
     unitDB = (UnitDB) Resources.Load("UnitDatabase");
 }