Exemplo n.º 1
0
        /// <summary>
        /// Resets rectangle array and color array.
        /// </summary>
        public void Reset()
        {
            Debug.debugMessage("GAME: Start", 1);
            checkRow.Reset();
            placedrect = new Rectangle[2];
            //reset all stored colors
            storedColor = new Brush[0];
            List <Brush> addcolor = storedColor.ToList();

            addcolor.Add(currentColor);
            addcolor.Add(currentColor);
            storedColor = addcolor.ToArray();
            checkRow    = InstanceManager.resetRow();
            setShape();
        }
Exemplo n.º 2
0
 public InstanceManager(Form1 form)
 {
     grabForm     = form;
     sound        = new SFX();
     rand         = new Random();
     predict      = new Prediction();
     rowCheck     = new RowCheck();
     gamepad      = new GamepadSupport();
     rotate       = new Rotate();
     nextShape    = new NextShape();
     move         = new Move();
     rotCheck     = new RotateCheck();
     ply          = new Player();
     gameSettings = new GameSettings();
     getGameGraphics();
 }
Exemplo n.º 3
0
        public Player()
        {
            sfx          = InstanceManager.getSound();
            checkRow     = InstanceManager.getRowCheck();
            confirmTimer = InstanceManager.getMainForm().confimTimer;
            gravityTimer = InstanceManager.getMainForm().gravityTimer;
            nextShapeBox = InstanceManager.getMainForm().nextShapeBox;
            predict      = InstanceManager.getPredict();
            rand         = InstanceManager.getRandom();

            debugFont = new Font("Arial", 12.0F);

            //setup rows, placedrectangles, etc
            placedrect  = new Rectangle[2];
            storedColor = new Brush[0];
            rows        = new Rectangle[2];
            rand        = new Random();

            List <Brush> addcolor = storedColor.ToList();

            addcolor.Add(currentColor);
            addcolor.Add(currentColor);
            storedColor = addcolor.ToArray();

            for (int y = 0; y < 20; y++) // makes a 10x20 grid
            {
                for (int x = 0; x < 10; x++)
                {
                    List <Rectangle> addtile = rows.ToList();
                    addtile.Add(new Rectangle(x * 32, y * 32, 32, 32));
                    rows = addtile.ToArray();
                }
            }

            InstanceManager.getNextShape().generateNextShape();
        }
Exemplo n.º 4
0
        //void DoXml(DataTable dt)
        //{
        //    StreamWriter sw = new StreamWriter(JsonPath + "\\" + tableName + ".xml", false, Encoding.GetEncoding("UTF-8"));
        //    sw.WriteLine("<?xml version=\"1.0\" encoding=\"utf-8\" ?>");
        //    sw.WriteLine("<" + tableName + ">");
        //    for (int i = 1; i < dt.Rows.Count; i++)
        //    {
        //        if (dt.Columns.Count == 0 || dt.Rows[i][0].ToString().Length == 0)
        //            continue;

        //        sw.WriteLine("\t\t<" + tableName + ">");
        //        for (int j = 0; j < dt.Columns.Count; j++)
        //        {
        //            if (dataType.ContainsKey(columnsName[j]))
        //                sw.WriteLine("\t\t\t<" + columnsName[j] + ">" + dt.Rows[i][j].ToString() + "</" + columnsName[j] + ">");
        //        }
        //        sw.WriteLine("\t\t</" + tableName + ">");
        //    }
        //    sw.WriteLine("</" + tableName + ">");
        //    sw.Flush();
        //    sw.Close();
        //}

        void DoJson(DataTable dt, int skipRow, string checkScript = "")
        {
            try
            {
                using (StreamWriter sw = new StreamWriter(JsonPath + "\\" + tableName + ".json", false, Encoding.GetEncoding("UTF-8")))
                {
                    sw.Write("[");

                    LuaEnv   checkEnv = null;
                    RowCheck rowCheck = null;

                    if (checkScript.Length > 0)
                    {
                        checkEnv = new LuaEnv();
                        checkEnv.DoString(checkScript);
                        rowCheck = checkEnv.Global.Get <RowCheck>("RowCheck");
                    }

                    Dictionary <string, string> rowData = new Dictionary <string, string>();

                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        if (dt.Columns.Count == 0 || dt.Rows[i][0].ToString().Length == 0)
                        {
                            continue;
                        }

                        rowData.Clear();

                        if (i > 0)
                        {
                            sw.Write(",");
                        }

                        sw.Write("[");
                        for (int j = 0; j < dt.Columns.Count; j++)
                        {
                            if (j > 0)
                            {
                                sw.Write(",");
                            }

                            var datatype = dataType[columnsName[j]];
                            if (IsBaseDataType(datatype))
                            {
                                //sw.Write(string.Format("\"{0}\":{1}", columnsName[j], dt.Rows[i][j].ToString()));
                                sw.Write(dt.Rows[i][j].ToString());
                            }
                            else
                            {
                                sw.Write(string.Format("\"{0}\"", dt.Rows[i][j].ToString()));
                            }

                            rowData.Add(columnsName[j], dt.Rows[i][j].ToString());
                        }
                        sw.Write("]");

                        var sRet = rowCheck?.Invoke(rowData);
                        if (null != sRet && sRet != "ok")
                        {
                            Form1.AddInfoMessage(string.Format("Row {0} Column ", skipRow + i + 1) + sRet, InfoType.Error);
                            //break;
                        }
                    }
                    sw.Write("]");
                    sw.Flush();
                    sw.Close();
                    codeGen(CodePath, tableName, columnsName, dataType, fieldConstraint);
                }
            }
            catch (Exception ex)
            {
                Form1.AddInfoMessage(ex.Message, InfoType.Error);
            }
        }
Exemplo n.º 5
0
 public void SetRowCheck(RowCheck rowCheck)
 {
     this.rowCheck = rowCheck;
 }
Exemplo n.º 6
0
        //处理数据源
        private void DealSource()
        {
            InfoReport(new ReportArgs {
                Message = "执行数据检测..."
            });

            foreach (var item in config.Mappings)
            {
                if (item.Macro != Macro.None)
                {
                    source.Columns.Add(new DataColumn(item.DBColumn, MappingType(item)));
                }
                else
                {
                    if (!source.Columns.Contains(item.FileColumn))
                    {
                        WarningReport(new ReportArgs
                        {
                            Message = $"列[{item.FileColumn}]不存在"
                        });
                    }
                }
            }

            if (WarningCount > 0)
            {
                throw new ImportException("数据列校验异常,导入终止");
            }

            source = source.DefaultView.ToTable(false, config.Mappings.Select(p => p.FileColumn).ToArray());
            int rowIndex = 0;//数据行号

            foreach (DataRow row in source.Rows)
            {
                //检测非None宏类型
                foreach (var item in config.Mappings.Where(p => p.Macro != Macro.None))
                {
                    row[item.DBColumn] = MacroValue(item);
                }


                //检测必输栏位
                foreach (var item in config.Mappings.Where(p => p.AllowNull == false))
                {
                    if (row[item.FileColumn] == null || row[item.FileColumn].ToString() == "")
                    {
                        WarningReport(new ReportArgs
                        {
                            Message = $"第{rowIndex + 2}行,列[{item.FileColumn}]不允许空值."
                        });
                    }
                }

                RowCheck?.Invoke(this, row, rowIndex, config);
                rowIndex++;
            }
            if (WarningCount > 0)
            {
                throw new ImportException("数据检测异常,导入终止");
            }
        }
Exemplo n.º 7
0
 public static RowCheck resetRow()
 {
     return(rowCheck = new RowCheck());
 }