public Bar(EBarType BarType, DisplayInfo dInfo, IOperator Operator) { this.dInfo = dInfo; this.Operator = Operator; mBar = moldBar = BarType; gh = new Image[4]; gh[0] = new Bitmap(Main.ResourceDirectory + "bar.bmp"); gh[1] = new Bitmap(Main.ResourceDirectory + "barsecond.bmp"); gh[2] = new Bitmap(Main.ResourceDirectory + "barthird.bmp"); gh[3] = new Bitmap(Main.ResourceDirectory + "barcatcher.bmp"); Bitmap bi = gh[0] as Bitmap; if (mBar == EBarType.SHORT) { Width = (int)bi.Width / 2; SPEED = 16; } else { Width = (int)bi.Width; } Height = (int)bi.Height; CenterX = dInfo.Width / 2; CenterY = 540; Reset(); IsDead = false; IsMove = false; }
public Ranking(int score, EBarType barnum, DisplayInfo dInfo, IOperator Operator) { this.dInfo = dInfo; this.Operator = Operator; try { rankGh = new Bitmap(Main.ResourceDirectory + "ranking.png"); gh = new Image[3]; gh[0] = new Bitmap(Main.ResourceDirectory + "bar.bmp"); gh[1] = new Bitmap(Main.ResourceDirectory + "barsecond.bmp"); gh[2] = new Bitmap(Main.ResourceDirectory + "barthird.bmp"); newgh = new Bitmap(Main.ResourceDirectory + "new.bmp"); } catch (Exception) { } selectSoundFlag = false; decisionSoundFlag = false; IsDead = false; scrollspeed = 1; end = false; scorey = 0; scroll = true; index = -1; // 配列の一番最初は添え字が0なため Save(score, barnum); }
public static void ReflectVertical(Ball ball, Bar bar, EBarType BarType) { if (Main.CatchBallEnables && bar.IsBallCatch)// ボールがバーにくっつく状態 { ball.IsCaught = true; ball.DX = ball.DY = 0; ball.IsStop = true; ball.CatchXOffset = ball.CenterX - bar.CenterX; bar.IsMove = false; } else if (ball.CenterX < bar.CenterX - bar.EnlargedWidth / 2 * 2 / 3 && ball.CenterX > bar.CenterX + bar.EnlargedWidth / 2 * 2 / 3) { bar.IsMove = false; if (BarType == EBarType.SHORT) { ball.LvUp(1); } ball.DY = -ball.DY; ball.CenterY = ball.CenterY - 5; Console.WriteLine("Reflect Vertical " + (ball.DY > 0 ? "↓" : "↑")); } else { if (ball.CenterX < bar.CenterX + 10 && ball.CenterX > bar.CenterX - 10) { ball.Penetration(); ball.LvUp(1); // 速度が上がって短時間貫通化 } bar.IsMove = false; if (BarType == EBarType.SHORT) { ball.LvUp(1); } ball.DY = -ball.DY; ball.CenterY = ball.CenterY - 5; Console.WriteLine("Reflect Vertical " + (ball.DY > 0 ? "↓" : "↑")); } }
public CBarCOM(EBarType barType, int idNo = 0, string name = "IBarCode") { this._idNo = idNo; this._name = name; this._barType = barType; object obj = load(barType.ToString()); if (obj != null) { _devBar = (IBarCode)obj; _devBar.OnRecved += new OnRecvHandler(onRecvTriger); this._comMode = _devBar.comMode; } }
private void cmbBarType_SelectedIndexChanged(object sender, EventArgs e) { EBarType barType = (EBarType)Enum.Parse(typeof(EBarType), cmbBarType.Text); if (comMon == null) { comMon = new CBarCOM(barType, 0, cmbBarType.Text); if (comMon.comMode == EComMode.SerialPort) { cmbCOM.Enabled = true; txtSerIP.Enabled = false; labSetting.Text = CLanguage.Lan("串口波特率:"); if (cmbBarType.Text == "SR700") { txtBand.Text = "115200,E,8,1"; } else { txtBand.Text = "115200,N,8,1"; } } else { cmbCOM.Enabled = false; txtSerIP.Enabled = true; labSetting.Text = CLanguage.Lan("TCP端口:"); if (cmbBarType.Text == "SR710_TCP") { txtSerIP.Text = "192.168.1.125"; txtBand.Text = "10001"; } else { txtBand.Text = "10000"; } } comMon = null; } }
// セーブデータ作成 public void Save(int xscore, EBarType xbarnum) { // 日付取得 // 数値を入れる。日付は作成日 // 必要な変数を宣言する DateTime dtNow = DateTime.Now; // 年 (Year) を取得する int iYear = dtNow.Year; // 月 (Month) を取得する int iMonth = dtNow.Month; // 日 (Day) を取得する int iDay = dtNow.Day; // Saveファイルを開く //保存した内容を復元する XmlSerializer serializer = new XmlSerializer(typeof(SaveGameData[])); System.IO.FileStream fs1 = null; try { try { System.IO.FileStream fs2 = null; try { // あれば開く 場所はC:\Users\大輔\Desktop\TSBBC\blockcrash\BlockCrashGUI\bin\Debug fs2 = new System.IO.FileStream("savedata.xml", System.IO.FileMode.Open); // 読み込み saved = (SaveGameData[])serializer.Deserialize(fs2); } finally { if (fs2 != null) { fs2.Close(); } } fs1 = new System.IO.FileStream("savedata.xml", System.IO.FileMode.Create); // 再作成 } catch (Exception) { // 開けなかったらCreate fs1 = new System.IO.FileStream("savedata.xml", System.IO.FileMode.Create); //作成 for (int i = 0; i < 20; ++i) // 配列20 { saved[i] = new SaveGameData(); if (i == 19) // デバック用に最下位は0を入力 { saved[i].Score = 0; } else // 数値は最上位が30000, { saved[i].Score = 30000 - (i + 1) * 1500; } // BarNumはランダムで EBarType bt = (EBarType)(Main.rand.Next() % 3 + 1); saved[i].BarNum = bt; saved[i].Year = iYear; saved[i].Month = iMonth; saved[i].Date = iDay; } } SaveGameData oldscore = new SaveGameData(); SaveGameData newsave = new SaveGameData(); // 新しいデータを登録 //コンストラクタ作るのめんどかった newsave.Score = xscore; //newsave.BarNum = xbarnum -1; newsave.BarNum = xbarnum; newsave.Year = iYear; newsave.Month = iMonth; newsave.Date = iDay; List <SaveGameData> saveGames = new List <SaveGameData>(saved); saveGames.Add(newsave); var DescendingOrder = saveGames.OrderByDescending(a => a.Score).Take(20); index = new List <SaveGameData>(DescendingOrder).FindIndex(a => Object.ReferenceEquals(newsave, a)); saved = DescendingOrder.ToArray(); serializer.Serialize(fs1, saved); } finally { if (fs1 != null) { fs1.Close(); } } }
private void btnOpen_Click(object sender, EventArgs e) { try { btnOpen.Enabled = false; if (cmbCOM.Text == "" && txtSerIP.Text == string.Empty) { labStatus.Text = CLanguage.Lan("请输入串口编号"); labStatus.ForeColor = Color.Red; return; } string er = string.Empty; if (comMon == null) { if (!Enum.IsDefined(typeof(EBarType), cmbBarType.Text)) { labStatus.Text = CLanguage.Lan("找不到类型") + "【" + cmbBarType.Text + "】"; labStatus.ForeColor = Color.Red; return; } EBarType barType = (EBarType)Enum.Parse(typeof(EBarType), cmbBarType.Text); comMon = new CBarCOM(barType, 0, cmbBarType.Text); string comName = string.Empty; string comSetting = string.Empty; if (comMon.comMode == EComMode.SerialPort) { comName = cmbCOM.Text; comSetting = txtBand.Text; } else { comName = txtSerIP.Text; comSetting = txtBand.Text; } if (!comMon.Open(comName, out er, comSetting)) { labStatus.Text = er; labStatus.ForeColor = Color.Red; comMon = null; return; } btnOpen.Text = CLanguage.Lan("关闭"); labStatus.Text = CLanguage.Lan("成功打开串口"); labStatus.ForeColor = Color.Blue; cmbCOM.Enabled = false; cmbBarType.Enabled = false; txtSerIP.Enabled = false; txtBand.Enabled = false; } else { comMon.Close(); comMon = null; btnOpen.Text = CLanguage.Lan("打开"); labStatus.Text = CLanguage.Lan("关闭串口"); labStatus.ForeColor = Color.Blue; cmbCOM.Enabled = true; cmbBarType.Enabled = true; txtSerIP.Enabled = true; txtBand.Enabled = true; } } catch (Exception) { } finally { btnOpen.Enabled = true; } }
public Bar(Guid id, EBarType type) { Id = id; Type = type; }