void StartGameState() { if (bat.Left()) { bat.Add(-1); pref.SetInt("CurrentBatteries", bat.batteries); buttons.Show(buttons.startButton, false); //TEST if (!charging) { timeToReachForBat = CurrentTime() + waitingTime; charging = true; } display.Battery(bat.Get()); display.CurrentScore(0); _state.level = 0; scoreForNextLevel = levelScore[0]; timeToStartGame = CurrentTime() + 3; SetState("playCountDown"); } else { display.NotEnoughtBat(); //Posible animacion de la batería sound.BadLuck(); SetState("mainMenu"); } }
void Update() { float perc = Time.deltaTime / timeToCharge; float diff = battery.totalCapacity * perc; battery.Add(diff); }
// Update is called once per frame void Update() { if (battery.IsFilled()) { battery = new Battery((1 << ++level) * 100); } if (touchEnabled) { for (int i = 0; i < Input.touchCount; i++) { Touch touch = Input.GetTouch(i); if (touch.deltaTime > 0) { float speed = touch.deltaPosition.magnitude / touch.deltaTime; battery.Add(speed / Screen.height); } if (runner != null && runner.Tapped(touch)) { caught.Add(runner); runner.Remove(); runner = null; } } } foreach (Hamster h in caught) { battery.Add(h.GetEnergyOutput()); } battery.ResetRate(); if (runner == null && battery.GetAverageRate() > 4) { runner = new Hamster(hamster, WorldPoint(Random.Range(0, Screen.width), Random.Range(Screen.height / 16, Screen.height * 6 / 10))); } }
void OnEnable() { float amount = battery.totalCapacity * chargePercent; battery.Add(amount); }
private void InOven(object obj) { string code = obj.ToString().Split(',')[0]; int index = TengDa._Convert.StrToInt(obj.ToString().Split(',')[1], -1); string msg = string.Empty; string techNo = string.Empty; lock (locker) { try { List <Cell> cells = new List <Cell>(); List <TechStandard> techStandards = new List <TechStandard>(); if (Current.mes.IsAlive) { if (Current.mes.IsOffline) { Current.mes.IsOffline = false; } this.BeginInvoke(new MethodInvoker(() => { this.lbTip.Text = code + " 正在获取电芯数据和工艺参数..."; this.lbTip.ForeColor = Color.LightGreen; })); if (!MES.GetInfo(Current.ovens[i].Floors[j].Number, code, out techNo, out cells, out techStandards, out msg)) { this.BeginInvoke(new MethodInvoker(() => { this.lbTip.Text = string.Format("{0}: {1}", code, msg); this.lbTip.ForeColor = Color.Red; })); LogHelper.WriteError(string.Format("{0}: {1}", code, msg)); return; } this.BeginInvoke(new MethodInvoker(() => { this.lbTip.Text = code + " 获取数据成功"; this.lbTip.ForeColor = Color.LightGreen; })); LogHelper.WriteInfo(code + " 获取数据成功"); Thread.Sleep(100); } else { if (TengDa.WF.Current.user.Group.Level > 2 && !Current.mes.IsOffline) { Current.mes.IsOffline = true; } if (!Current.mes.IsOffline) { MesOfflineVerify m = new MesOfflineVerify(); DialogResult dr = m.ShowDialog(); if (dr == DialogResult.OK) { if (!Current.mes.IsOffline) { Current.mes.IsOffline = true; } } else { Error.Alert("无法连接至MES,无法入腔!"); return; } } } //料盒/托盘保存到数据库 Clamp clamp = new Clamp(); clamp.Code = code; clamp.EnterTime = DateTime.Now; clamp.FloorId = Current.ovens[i].Floors[j].Id; clamp.Location = index.ToString(); clamp.OutTime = TengDa.Common.DefaultTime; clamp.BakingStartTime = TengDa.Common.DefaultTime; clamp.BakingStopTime = TengDa.Common.DefaultTime; clamp.isUploaded = false; clamp.isFinished = false; clamp.techNo = techNo; int clampid = Clamp.Add(clamp, out msg); if (clampid < 1) { Error.Alert("clampid < 1"); return; } Current.ovens[i].Floors[j].Clamps.Add(new Clamp(clampid)); string clampids = string.Empty; foreach (Clamp c in Current.ovens[i].Floors[j].Clamps) { clampids += c.Id + ","; } Current.ovens[i].Floors[j].ClampIds = clampids.TrimEnd(','); this.BeginInvoke(new MethodInvoker(() => { ListViewItem li = new ListViewItem();//创建行对象 li.Text = (++clampNum).ToString(); li.SubItems.Add(code); li.SubItems.Add(""); this.lvClampCodes.Items.Add(li); })); clampCodes.Add(code); if (Current.mes.IsAlive) { //电芯数据保存到数据库 List <Battery> batteries = new List <Battery>(); for (int ii = 0; ii < cells.Count; ii++) { Battery battery = new Battery(); battery.Code = cells[ii].sfc_no; battery.ClampId = clampid; battery.Location = cells[ii].seq_no; batteries.Add(battery); } this.BeginInvoke(new MethodInvoker(() => { ListViewItem li_n = lvClampCodes.Items.Cast <ListViewItem>().First(x => x.SubItems[1].Text == code); if (li_n != null) { li_n.SubItems[2].Text = batteries.Count.ToString(); } })); if (!Battery.Add(batteries, out msg)) { this.BeginInvoke(new MethodInvoker(() => { this.lbTip.Text = code + " 电芯数据存入数据库失败!"; this.lbTip.ForeColor = Color.Red; })); LogHelper.WriteError(code + " 电芯数据存入数据库失败"); return; } this.BeginInvoke(new MethodInvoker(() => { this.lbTip.Text = code + " 电芯数据存入数据库成功!"; this.lbTip.ForeColor = Color.LightGreen; })); LogHelper.WriteInfo(code + " 电芯数据存入数据库成功!"); Thread.Sleep(100); //工艺参数保存到数据库 if (!TechStandard4DB.Add(techStandards, clampid, out msg)) { this.BeginInvoke(new MethodInvoker(() => { this.lbTip.Text = code + " 工艺参数存入数据库失败!"; this.lbTip.ForeColor = Color.Red; })); LogHelper.WriteError(code + " 工艺参数存入数据库失败"); return; } this.BeginInvoke(new MethodInvoker(() => { this.lbTip.Text = code + " 工艺参数存入数据库成功!"; this.lbTip.ForeColor = Color.LightGreen; })); LogHelper.WriteInfo(code + " 工艺参数存入数据库成功!"); } else if (Current.mes.IsOffline) { Battery battery = new Battery(); battery.Code = code + "-" + DateTime.Now.ToString("yyyyMMddHHmmss"); battery.ClampId = clampid; battery.Location = "1"; if (Battery.Add(battery, out msg) < 1) { this.BeginInvoke(new MethodInvoker(() => { this.lbTip.Text = code + " MES离线模式,生成电芯数据存入数据库失败!"; this.lbTip.ForeColor = Color.Red; })); LogHelper.WriteInfo(code + " MES离线模式,生成电芯数据存入数据库失败!"); return; } this.BeginInvoke(new MethodInvoker(() => { this.lbTip.Text = code + " MES离线模式,生成电芯数据存入数据库成功!"; this.lbTip.ForeColor = Color.LightGreen; })); LogHelper.WriteError(code + " MES离线模式,生成电芯数据存入数据库成功!"); Thread.Sleep(100); } } catch (Exception ex) { Error.Alert(ex.ToString()); } } }