private void getPlayers() { players.Clear(); using (FileStream r = File.Open("players.txt", FileMode.OpenOrCreate, FileAccess.ReadWrite)) { if (r.Length > 0) { using (StreamReader s = new StreamReader(r, true)) { String line; while ((line = s.ReadLine()) != null) { String name = line.Substring(0, line.IndexOf(",")); String id = line.Substring(name.Length + 2, 5); play temp = new play(); temp.N = name; temp.I = id; players.Add(temp); } } } } foreach (play player in players) { comboBox1.Items.Add(player.N); } }
void _MakeInstance() { if (instance == null) { instance = this; } }
private void init() { bp = new BossPlane(Image.FromFile("Resources/plane/boss.png"), this.Height, this.Width, Image.FromFile("Resources/plane/boss_boom.png"), 400); background = new Background(this.Height, this.Width); gem = new Gem(this.Height, this.Width); hp = new HeroPlane(Image.FromFile("Resources/plane/飞机5c.png"), this.Height, this.Width, Image.FromFile("Resources/plane/飞机5c_boom.png"), 100, Image.FromFile("Resources/plane/子弹1c.png"), 0); b = new Bitmap(this.Width, this.Height); gg = Graphics.FromImage(b); p = new List <Plane>(); p.Add(new Plane(Image.FromFile("Resources/plane/飞机1c.png"), this.Height, this.Width, Image.FromFile("Resources/plane/飞机1c_boom.png"), 10, Image.FromFile("Resources/plane/子弹3c.png"), 5)); p.Add(new Plane(Image.FromFile("Resources/plane/飞机2c.png"), this.Height, this.Width, Image.FromFile("Resources/plane/飞机2c_boom.png"), 5, Image.FromFile("Resources/plane/子弹2c.png"), 8)); p.Add(new Plane(Image.FromFile("Resources/plane/飞机3c.png"), this.Height, this.Width, Image.FromFile("Resources/plane/飞机3c_boom.png"), 20, Image.FromFile("Resources/plane/子弹1c.png"), 10)); p.Add(new Plane(Image.FromFile("Resources/plane/飞机4c.png"), this.Height, this.Width, Image.FromFile("Resources/plane/飞机4c_boom.png"), 15, Image.FromFile("Resources/plane/子弹5c.png"), 4)); p.Add(new Plane(Image.FromFile("Resources/plane/飞机6c.png"), this.Height, this.Width, Image.FromFile("Resources/plane/飞机6c_boom.png"), 40, Image.FromFile("Resources/plane/子弹4c.png"), 20)); p1 = new play(p[0].play); p1 += p[1].play; p1 += p[2].play; p1 = new play(p[0].play); p1 += p[1].play; p1 += p[2].play; p1 += p[3].play; p1 += p[4].play; setInterval(); }
public ActionResult DeleteConfirmed(string id) { play play = db.plays.Find(id); db.plays.Remove(play); db.SaveChanges(); return(RedirectToAction("Index")); }
public XmsCall(string a_callId) { this.CallId = a_callId; m_call = new call(); m_call_action = new call_action(); m_play = new play(); m_playrec = new playrecord(); m_playcollect = new playcollect(); }
private void Start() { //廣告,初始化(廣告服務 ID,啟動測試模式) Advertisement.Initialize(googlePlay, false); //廣告監聽 Advertisement.AddListener(this); player = FindObjectOfType <play>(); }
void Start() { pScript = gm.GetComponent <play>(); //pos = new Vector3(fish.transform.position.x, 0, -10f); m_ViewPositionX = 0; m_ViewPositionY = 0; m_ViewWidth = 1; m_ViewHeight = 1; m_OrthographicCamera.enabled = true; fishy = fish.GetComponent <playerMovement>(); m_OrthographicCamera.rect = new Rect(m_ViewPositionX, m_ViewPositionY, m_ViewWidth, m_ViewHeight); }
public ActionResult Edit([Bind(Include = "PlayerName,HandID,StartingStack,EndingStack,SeatPosition,HoleCard1,HoleCard2")] play play) { if (ModelState.IsValid) { db.Entry(play).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.HandID = new SelectList(db.plays, "HandID", "StartingStack", play.HandID); ViewBag.PlayerID = new SelectList(db.players, "Name", "Name", play.PlayerID); return(View(play)); }
void Start() { pScript = gm.GetComponent <play>(); difficulty = 0; pos = transform.position; anchored = false; yStart = transform.position.y; xStart = transform.position.x; fishy = fish.GetComponent <playerMovement>(); started = false; wait1 = 0f; wait2 = 2f; }
// GET: plays/Delete/5 public ActionResult Delete(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } play play = db.plays.Find(id); if (play == null) { return(HttpNotFound()); } return(View(play)); }
public void game() { ChatText.text += main_script.my_name; ChatText.text += "玩得很開心\n"; GameObject play_obj = GameObject.Find("/UI/Button/遊戲"); play play_script = play_obj.GetComponent <play>(); play_script.nowHP += 20; GameObject src_obj = GameObject.Find("Pet"); pet_controll_script src_script = src_obj.GetComponent <pet_controll_script>(); src_script.check_ac(); ++src_script.cnt; }
// GET: plays/Edit/5 public ActionResult Edit(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } play play = db.plays.Find(id); if (play == null) { return(HttpNotFound()); } ViewBag.HandID = new SelectList(db.plays, "HandID", "StartingStack", play.HandID); ViewBag.PlayerID = new SelectList(db.players, "Name", "Name", play.PlayerID); return(View(play)); }
// Use this for initialization void Start() { hatSprite = hat.GetComponent <SpriteRenderer>(); pScript = gm.GetComponent <play>(); pos = transform.position; //tr = transform; sprite = GetComponent <SpriteRenderer>(); hooked = false; lost = false; saved = false; rot = 0; tim = .005f; timHooked = .05f; // rotation newQuaternion = new Quaternion(); newQuaternion.Set(0, 0, z, 0); lookingRight = true; onlyOnce = false; spawner = 1f; }
void Awake() { ins = this; }
// Use this for initialization void Start() { pl = gm.GetComponent <play>(); ySpd = .1f; xScale = .1f; }
public ActionResult ContactUs(play.Site.ViewModels.ContactUs contactUs) { Utils.Mail.SendToShariContactUs(contactUs.Email, contactUs.Name, contactUs.Message); return Redirect("~/contactussuccess"); }
static void Main(string[] args) { player player1 = new player(); player player2 = new player(); player1.score = 0; player2.score = 0; Console.WriteLine("Welcome to PIG"); Console.WriteLine("What is your name?"); player1.name = Console.ReadLine(); Console.WriteLine("What is the computer's name?"); player2.name = Console.ReadLine(); int targetScore = 0; Console.WriteLine("What are you playing to?"); targetScore = int.Parse(Console.ReadLine()); //game loop while (player1.score < targetScore && player2.score < targetScore) { //add scoreboard here Console.WriteLine("**************************************"); Console.WriteLine("{0}'s score: {1}", player1.name, player1.score); Console.WriteLine("{0}'s score: {1}", player2.name, player2.score); Console.WriteLine("**************************************"); int turnScore = 0; //player turn loop while (true) { int diceRoll = Roll(); Console.WriteLine("It's your turn, you roll a {0}", diceRoll); if (diceRoll == 1) { Console.WriteLine("You rolled a 1, you lose all your points for this turn."); break; } else { turnScore += diceRoll; Console.WriteLine("You total for this turn is {0}", turnScore); Console.WriteLine("Do you want to hold or roll?"); string play2Name = Console.ReadLine(); play play2 = (play)Enum.Parse(typeof(play), play2Name); if (play2 == play.hold) { player1.score += turnScore; break; } else { Console.WriteLine("You decide to roll again"); } } } Console.WriteLine("**************************************"); turnScore = 0; Thread.Sleep(1000); //Breaks the loop if the player wins if (player1.score >= targetScore || player2.score >= targetScore) { break; } //computer turn loop while (true) { int diceRoll = Roll(); Console.WriteLine("{0} rolls a {1}", player2.name, diceRoll); if (diceRoll == 1) { Console.WriteLine("{0} rolled a 1, and loses all their points for this turn.", player2.name); break; } else { turnScore += diceRoll; Console.WriteLine("{0}'s total for this turn is {1}", player2.name, turnScore); //sleep to rethread random number, found idea on stackoverflow.com Thread.Sleep(750); //insert computer ai here Random rnd = new Random(); int computerRand = rnd.Next(1, 10); if (computerRand % 2 == 0) { Console.WriteLine("{0} chooses to hold", player2.name); player2.score += turnScore; break; } else { Console.WriteLine("{0} chooses to roll again", player2.name); } } } } Console.WriteLine("**************************************"); Console.WriteLine("Final Score:"); Console.WriteLine("{0}'s score: {1}", player1.name, player1.score); Console.WriteLine("{0}'s score: {1}", player2.name, player2.score); Console.WriteLine("**************************************"); if (player1.score < player2.score) { Console.WriteLine("{0} wins! Better luck next time.", player2.name); } else { Console.WriteLine("You win!"); } Console.ReadLine(); }
private void GetChance(play a, int dim, int[] hand) { Random r = new Random(); int i, j; double ans, win = 0, lost = 0 /*,matches=0*/; int[] v = new int[7], w = new int[7]; ///v-mana lui a ///w- mana adversarului v[0] = hand[0]; csel[v[0]] = 1; v[1] = hand[1]; csel[v[1]] = 1; if (dim < 1) { for (i = 0; i < 100000; ++i) { for (j = 0; j < 2; ++j) { w[j] = UnselectedCard(r.Next(52)); csel[w[j]] = 1; } for (j = 2; j < 7; ++j) { w[j] = UnselectedCard(r.Next(52)); csel[w[j]] = 1; v[j] = w[j]; } Hand h1 = new Hand(v); Hand h2 = new Hand(w); if (h1.k != h2.k) { if (h1 < h2) { ++lost; } else { ++win; } } for (j = 0; j < 7; ++j) { csel[w[j]] = 0; } } ans = win * 100 / (win + lost); a.chance = ans; } else { if (dim < 4) { double t_win, r_win, t_lost, r_lost; int it1, it2; Hand h1, h2; for (i = 2; i < 5; ++i) { w[i] = table[i - 2]; v[i] = w[i]; } for (i = 51; i > -1; --i) { if (csel[i] > 0) { continue; } csel[i] = 1; t_win = 0; t_lost = 0; for (j = 50; j > -1; --j) { if (csel[j] > 0) { continue; } csel[j] = 1; r_win = 0; r_lost = 0; for (it1 = 51; it1 > -1; --it1) { if (csel[it1] > 0) { continue; } csel[it1] = 1; for (it2 = it1 - 1; it2 > -1; --it2) { if (csel[it2] > 0) { continue; } w[0] = it1; w[1] = it2; v[5] = i; v[6] = j; w[5] = v[5]; w[6] = v[6]; h1 = new Hand(v); h2 = new Hand(w); //if(h1.k!=h2.k) //{ if (h1 < h2) { ++r_lost; } else { ++r_win; } //} } csel[it1] = 0; } csel[j] = 0; a.rc[i, j] = r_win * 100 / (r_lost + r_win); a.rc[j, i] = a.rc[i, j]; t_win += r_win; t_lost += r_lost; } csel[i] = 0; a.tc[i] = t_win * 100 / (t_win + t_lost); win += t_win; lost += t_lost; } a.chance = win * 100 / (win + lost); win += lost; } } csel[v[0]] = 0; csel[v[1]] = 0; }