private void kougeki(Cha suru, Cha sareru) { text.text = ""; // 音を出す this.audioSource.PlayOneShot(audioSource.clip); text.text = suru.getName() + " が" + sareru.getName() + " にこうげきした!" + "\n"; // ダメージは 10% のランダム補正を入れる int kougeki = suru.getKougeki() + (int)(suru.getKougeki() * Random.Range(-0.1f, 0.1f)); text.text = text.text + kougeki + " のダメージ!" + "\n"; bool sibou = sareru.kougekiSareta(kougeki); if (sibou) { text.text = text.text + sareru.getName() + " をたおした!" + "\n"; // 敵の時はお金を獲得 if (sareru.getIsTeki()) { sentouSaveData.addOkane(sareru.getOkane()); } } }
public static Tu getTu(string name) { Tu tu = null; if (name == "San") { Console.WriteLine("请依次输入三边长:"); try { int a = Int32.Parse(Console.ReadLine()); int b = Int32.Parse(Console.ReadLine()); int c = Int32.Parse(Console.ReadLine()); tu = new San(a, b, c); } catch (Exception a) { Console.WriteLine("输入错误:" + a.Message); } } else if (name == "Yuan") { Console.WriteLine("请输入半径:"); try { int a = Int32.Parse(Console.ReadLine()); tu = new Yuan(a); } catch (Exception a) { Console.WriteLine("输入错误:" + a.Message); } } else if (name == "Zhe") { Console.WriteLine("请输入边长:"); try { int a = Int32.Parse(Console.ReadLine()); tu = new Zhe(a); } catch (Exception a) { Console.WriteLine("输入错误:" + a.Message); } } else if (name == "Cha") { Console.WriteLine("请依次输入两边长:"); try { int a = Int32.Parse(Console.ReadLine()); int b = Int32.Parse(Console.ReadLine()); tu = new Cha(a, b); } catch (Exception a) { Console.WriteLine("输入错误:" + a.Message); } } return(tu); }
public void DiceRoll() { float first = 0, second = 0, third = 0; for (int i = 0; i < 5; i++) { Roll[i] = Random.Range(1, 7); } for (int j = 0; j < 5; j++) { if (Roll[j] > first) { third = second; second = first; first = Roll[j]; } else if (Roll[j] > second) { third = second; second = Roll[j]; } else if (Roll[j] > third) { third = Roll[j]; } } total = first + second + third; if (Total.Count < 6) { Total.Add(total); Output1.text = Roll[0].ToString(); Output2.text = Roll[1].ToString(); Output3.text = Roll[2].ToString(); Output4.text = Roll[3].ToString(); Output5.text = Roll[4].ToString(); OutputTotal.text = total.ToString(); } StrMod.text = "+2"; DexMod.text = "+2"; ConMod.text = "+2"; IntMod.text = "+2"; WisMod.text = "+2"; ChaMod.text = "+2"; List <string> options = new List <string>(); if (Str.options.Count < 6) { options.Add(Total[Total.Count - 1].ToString()); Str.AddOptions(options); Dex.AddOptions(options); Con.AddOptions(options); Int.AddOptions(options); Wis.AddOptions(options); Cha.AddOptions(options); } }
static void Main(string[] args) { // Poderia ser Cafe: Tipo "identificador do objeto" // new Construtor(); var cafe = new Cafe(); cafe.CafeId = Guid.NewGuid(); cafe.Forca = 3; cafe.PaisOrigem = "Brasil"; Console.WriteLine(cafe.CafeId); Console.WriteLine(cafe.Forca); Console.WriteLine(cafe.PaisOrigem); QuebraLinha(); Bebida bebida = new Bebida(); bebida.BebidaId = Guid.NewGuid(); bebida.DataDeValidade = DateTime.Now; bebida.Nome = "Café com Leite"; bebida.Temperatura = 3; int temp = bebida.ObterTemperaturaParaServir(); Console.WriteLine(temp); Console.WriteLine(bebida.Nome); QuebraLinha(); Cha cha = new Cha(); Console.WriteLine(cha.ChaId); Console.WriteLine(cha.Sabor); QuebraLinha(); Console.WriteLine("Café Id: {0} => Forca: {1}: Pais: {2}", cafe.CafeId, cafe.Forca, cafe.PaisOrigem); QuebraLinha(); Console.Write("Entre com o sabor do Chá: "); string texto = Console.ReadLine(); var cha3 = new Cha(texto); Console.WriteLine(cha3); }
// Constructor // // 1- Report Title // 2- Table Start Name // 3- Table Name // 4- Field List // 5- ID Start // 6- ID End // 7- Order // 8- Custom Qry List<> //string pRptTitle, string pFromDate, string pToDate public frmPrintViewerSubRpt( string pRptTitle, string p, string p_2, string pStoreProcName, string plstField, string plstType, string plstValue, DataSet pDs, Cha.PrintViewer.ReportClass prpt1, string pQtyType ) { InitializeComponent(); fRptTitle = pRptTitle; fp = p; fp_2 = p_2; fStoreProcName = pStoreProcName; flstField = plstField; flstType = plstType; flstValue = plstValue; fDs = pDs; frpt1 = prpt1; fQtyType = pQtyType; // try { fRptTitle = pRptTitle; this.Text = fRptTitle; } catch (Exception ex) { MessageBox.Show("Exception-Initialize: " + ex.Message, this.Text.ToString()); } }
public void kougekisuru(Cha suru, Cha sareru) { List <Cha> list = new List <Cha>(); list.Add(suru); list.Add(sareru); kougekiMap.Add(list); if (kougekiMap.Count == 2) { List <Cha> teki = this.tekiKantoku.gettekikougeki(); // 敵リスト作成 this.tekiList.Add(teki); kougekiMap.Add(teki); // 素早さ順にする kougekiMap.Sort((c1, c2) => (c2[0].getSpeed() - c1[0].getSpeed())); this.kougekiKaishi(); } }
async private void kougekiKaishi() { // 敵を全員倒したら field に戻る bool taoshita = false; foreach (List <Cha> list in kougekiMap) { Cha suru = null; foreach (Cha c in list) { // 攻撃する人を設定する if (suru == null) { suru = c; continue; } // 攻撃される人に攻撃する this.kougeki(suru, c); await Task.Delay(1000); foreach (List <Cha> t in this.tekiList) { if (t[0] != null) { taoshita = false; break; } else { taoshita = true; } } } if (taoshita) { break; } } // リストを初期化する this.kougekiMap = new List <List <Cha> >(); this.tekiList = new List <List <Cha> >(); if (taoshita) { //シーン移動 sentouSaveData.setOmoko(omoko.getHp(), omoko.getKougeki(), omoko.getSpeed(), omoko.getEx()); sentouSaveData.setTouyama(touyama.getHp(), touyama.getKougeki(), touyama.getSpeed(), touyama.getEx()); await Task.Delay(3000); SceneManager.LoadScene("field"); } // ボタンの色を戻す this.touyamaButton.GetComponent <Image>().color = Color.white; this.omokoButton.GetComponent <Image>().color = Color.white; }