void CheckHP() { P1.SetActive(true); P2.SetActive(true); P3.SetActive(true); P4.SetActive(true); if (CurrHP <= 3) { P4.SetActive(false); } if (CurrHP <= 2) { P3.SetActive(false); } if (CurrHP <= 1) { P2.SetActive(false); } if (CurrHP <= 0) { P1.SetActive(false); } }
public void playGame() { Game.PrintGame(); while (true) { Console.WriteLine(P1.GetName() + "Play"); P1.PickBall(Game); if (Game.IsGameOVer()) { Console.WriteLine(P1.GetName() + "lose"); Console.WriteLine(P2.GetName() + " win"); break; } Game.PrintGame(); Console.WriteLine(P2.GetName() + " play"); P2.PickBall(Game); if (Game.IsGameOVer()) { Console.WriteLine(P2.GetName() + "lose"); Console.WriteLine(P1.GetName() + " win"); break; } Game.PrintGame(); } }
private void ReflectInternal(Circle c) { // Reflecting to a line? if (IsPointOn(c.Center)) { // Grab 2 points to reflect to P1/P2. // We'll use the 2 points that are 120 degrees from c.Center. Vector3D v = c.Center - this.Center; v.RotateXY(2 * Math.PI / 3); P1 = c.ReflectPoint(this.Center + v); v.RotateXY(2 * Math.PI / 3); P2 = c.ReflectPoint(this.Center + v); Radius = double.PositiveInfinity; Center.Empty(); } else { // NOTE: We can't just reflect the center. // See http://mathworld.wolfram.com/Inversion.html double a = Radius; double k = c.Radius; Vector3D v = Center - c.Center; double s = k * k / (v.MagSquared() - a * a); Center = c.Center + v * s; Radius = Math.Abs(s) * a; P1.Empty(); P2.Empty(); } }
private void btnCalcular_Click(object sender, EventArgs e) { try { double Inv1 = Convert.ToDouble(txtInversion1.Text), Inv2 = Convert.ToDouble(txtInversion2.Text), Inv3 = Convert.ToDouble(txtInversion3.Text), P1, P2, P3, Total; if ((Inv1 > 0 && Inv2 > 0) && Inv3 > 0) { Total = Inv1 + Inv2 + Inv3; P1 = Inv1 / Total; P2 = Inv2 / Total; P3 = Inv3 / Total; txtPer1.Text = P1.ToString("P2"); txtPer2.Text = P2.ToString("P2"); txtPer3.Text = P3.ToString("P2"); txtTotal.Text = Total.ToString("C2"); } else { MessageBox.Show("Los números ingresados deben corresponder a cantidades positivas de dinero, favor revisar la información", "Datos no validos", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception) { MessageBox.Show("Los datos ingresados deben ser números reales", "Error de Datos", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void Rotate(double alpha) { P1.Rotate(alpha, Center); P2.Rotate(alpha, Center); P3.Rotate(alpha, Center); P4.Rotate(alpha, Center); }
/// <summary> /// allocate correct pool type and add it to types /// </summary> internal static AbstractStoragePool newPool(string name, AbstractStoragePool superPool, List <AbstractStoragePool> types) { try { switch (name) { case "a": return(superPool = new P0(types.Count)); case "b": return(superPool = new P1(types.Count, (P0)superPool)); case "d": return(superPool = new P2(types.Count, (P1)superPool)); case "c": return(superPool = new P3(types.Count, (P0)superPool)); default: if (null == superPool) { return(superPool = new BasePool <SkillObject>(types.Count, name, AbstractStoragePool.noKnownFields, AbstractStoragePool.NoAutoFields)); } else { return(superPool = superPool.makeSubPool(types.Count, name)); } } } finally { types.Add(superPool); } }
/// <summary> /// Samples the original image with the given sample steps and draws the resulting over scaled image to the panel /// </summary> public void ChangeResolution(int sampleStepX, int sampleStepY) { if (colors.Count > 0) { var dict = new Dictionary <P2, int>(); foreach (var kvp in regionSeeds) { int superX = kvp.Key.X * sampleStep.X; int superY = kvp.Key.Y * sampleStep.Y; var nKey = new P2(superX / sampleStepX, superY / sampleStepY); if (!dict.ContainsKey(nKey)) { dict.Add(nKey, kvp.Value); } } regionSeeds = dict; } sampleStep = new P2(sampleStepX, sampleStepY); img_gray_small = new Frame(img_gray.Width / sampleStepX, img_gray.Height / sampleStepY); Imaging.Scale(img_gray, img_gray_small, InterpolationType.NearestNeighbor); var tmp = new Frame(img_org.Width, img_org.Height); Imaging.Scale(img_gray_small, tmp, InterpolationType.NearestNeighbor); if (img_display != null) { img_display.Dispose(); } img_display = tmp.GetBitmap(); Invalidate(); }
public void PlayGame() { game.PrintGame(); while (true) { Console.WriteLine(P1.GetName() + " turn"); P1.PickBall(game); if (game.IsGameOver()) { Console.WriteLine(P1.GetName() + " loses "); Console.WriteLine(P2.GetName() + " wins "); break; } game.PrintGame(); Console.WriteLine(P2.GetName() + "turn"); P2.PickBall(game); if (game.IsGameOver()) { Console.WriteLine(P1.GetName() + " wins "); Console.WriteLine(P2.GetName() + " loses "); break; } game.PrintGame(); } }
private void P1_KeyDown(object sender, System.Windows.Input.KeyEventArgs e) { if (e.Key == System.Windows.Input.Key.Enter) { P2.Focus(); } }
public void EnchantThenDisenchant() { var mirage = C("Lingering Mirage"); var forest = C("Forest"); var disenchant = C("Disenchant"); Battlefield(P2, forest); Hand(P1, mirage); Hand(P2, disenchant); Exec( At(Step.FirstMain) .Cast(mirage, target: forest) .Verify(() => { True(P2.HasMana(Mana.Blue)); False(P2.HasMana(Mana.Green)); }), At(Step.SecondMain) .Cast(disenchant, target: mirage) .Verify(() => { False(P2.HasMana(Mana.Blue)); True(P2.HasMana(Mana.Green)); }) ); }
public Form1() { InitializeComponent(); string[] ports = SerialPort.GetPortNames(); cbxCom.Items.AddRange(ports); UART.ReadTimeout = 2000; //UART.DataReceived += new SerialDataReceivedEventHandler(data); UART.BaudRate = 115200; UART.Parity = Parity.None; UART.StopBits = StopBits.One; timer1.Interval = 100; cbxlevel.Text = "Low"; cbxtime.Text = "None"; btnback.Enabled = false; btnleft.Enabled = false; btnstop.Enabled = false; btnright.Enabled = false; btnstraight.Enabled = false; btnchay.Enabled = false; btndung.Enabled = false; btndung.BackColor = Color.FromArgb(33, 42, 52); cbx_auto.Enabled = false; cbx_man.Enabled = false; cbxlevel.Enabled = false; cbxtime.Enabled = false; P1.Hide(); P2.Hide(); P3.Hide(); P4.Hide(); P6.Hide(); P5.Show(); P5.BringToFront(); picturemenu.Hide(); //label1.Text = "tuannguyen"; //t = TestContext.Out; //Console.WriteLine("using TextWriter"); }
protected override void OnMouseMove(MouseEventArgs e) { base.OnMouseMove(e); if (recordMouseTrace) { int x = (e.X - AutoScrollPosition.X) / sampleStep.X; int y = (e.Y - AutoScrollPosition.Y) / sampleStep.Y; if (x >= 0 && x < img_gray_small.Width && y >= 0 && y < img_gray_small.Height) { var key = new P2(x, y); if (DeleteTrace) { regionSeeds.Remove(key); } else { if (regionSeeds.ContainsKey(key)) { regionSeeds[key] = activeRegion; } else { regionSeeds.Add(key, activeRegion); } } } Invalidate(); } }
public void PlayGame() { Game.PrintGame(); while (true) { Console.WriteLine(P1.GetName() + "'s turn"); P1.PickBall(Game); Game.PrintGame(); if (Game.IsGameOver()) { Console.WriteLine(P1.GetName() + " is lost !"); Console.WriteLine(P2.GetName() + " is a champion !"); break; } Console.WriteLine(P2.GetName() + "'s turn"); P2.PickBall(Game); Game.PrintGame(); if (Game.IsGameOver()) { Console.WriteLine(P2.GetName() + " is lost !"); Console.WriteLine(P1.GetName() + " is a champion !"); break; } } }
//play public void PlayGame() { Game.PrintGame(); while (true) { Console.Write(P1.GetName() + "turn "); P1.PickBalls(Game); Game.PrintGame(); if (Game.IsGameOver()) { Console.WriteLine(P1.GetName() + "loses"); Console.WriteLine(P2.GetName() + "Wins"); break; } Console.Write(P1.GetName() + "turn "); P2.PickBalls(Game); Game.PrintGame(); if (Game.IsGameOver()) { Console.WriteLine(P2.GetName() + " Loses"); Console.WriteLine(P1.GetName() + " Wins"); break; } } }
/// <summary> /// Segmentates the image using the seeds planted. /// </summary> public void Segmentate() { var seeds = new List <Vec2I>(); var labels = new List <int>(); foreach (var kvp in regionSeeds) { seeds.Add(new Vec2I(kvp.Key.X, kvp.Key.Y)); labels.Add(kvp.Value + 1); } var rwSeg = new RandomWalkerSegmenter <byte>(seeds.ToArray(), labels.ToArray()); var res = rwSeg.Segmentate(img_gray_small); for (int i = 0; i < img_gray_small.Width; i++) { for (int j = 0; j < img_gray_small.Height; j++) { int index = res[i][j] - 1; var pos = new P2(i, j); if (index >= 0 && !regionSeeds.ContainsKey(pos)) { regionSeeds.Add(pos, index); } } } Invalidate(); }
public NodeGrid(Sz2 <int> strides, IEnumerable <P1V <int, float> > tuples, int generation, int seed) { Strides = strides; Values = new float[Strides.Count()]; foreach (var tup in tuples) { Values[tup.X] = tup.V; } Generation = generation; Seed = seed; var randy = GenV.Twist(Seed); Noise = GenS.NormalSF32(randy, 0.0f, 1.0f).Take(Strides.Count()).ToArray(); NextSeed = randy.Next(); var Offhi = new P2 <int>(0, -1); var Offlo = new P2 <int>(0, 1); var Offlf = new P2 <int>(-1, 0); var Offrt = new P2 <int>(1, 0); Top = GridUtil.OffsetIndexes(Strides, Offhi); Bottom = GridUtil.OffsetIndexes(Strides, Offlo); Left = GridUtil.OffsetIndexes(Strides, Offlf); Right = GridUtil.OffsetIndexes(Strides, Offrt); }
public bool Intersects(Line line, out Vector intersection, bool infiniteLine = true) { intersection = Equation.GetIntersection(line); if (intersection.IsEmpty) { return(false); } else if (infiniteLine) { return(true); } var v1 = intersection - P1.ToVector(); var v2 = intersection - P2.ToVector(); if (!v1.Normalized.EqualOrClose(Direction, 0.0001) || v1.Length > Length.NormalizedValue) { return(false); } if (!v2.Normalized.EqualOrClose(Direction * -1, 0.0001) || v2.Length > Length.NormalizedValue) { return(false); } return(true); }
public void PlayGame() { Game.Printgame(); while (true) { Console.WriteLine(P1.GetName() + " play: "); P1.PickBalls(Game); Game.Printgame(); if (Game.IsgameOver()) { Console.WriteLine(P2.GetName() + " play: "); break; } Console.WriteLine("Player2 pickBall: "); P2.PickBalls(Game); Game.Printgame(); if (Game.IsgameOver()) { Console.WriteLine("Player2 lose!"); break; } } }
private void Start() { Time.timeScale = 0; Cursor.visible = false; Cursor.lockState = CursorLockMode.Locked; sceneChoice = GameObject.Find("SceneChoice"); SceneChoice sceneChoiceScript = sceneChoice.GetComponent <SceneChoice>(); pressSpace.SetActive(true); switch (sceneChoiceScript.Choice) { case (int)SceneChoice.GameMode.AI: racketRight.GetComponent <EnemyController>().enabled = true; AI.SetActive(true); break; case (int)SceneChoice.GameMode.Player: racketRight.GetComponent <MoveRacket>().enabled = true; P2.SetActive(true); break; } textScoreLeft.text = scoreLeft.ToString(); textScoreRight.text = scoreRight.ToString(); racketLeftStartPosition = racketLeft.transform.position; racketRightStartPosition = racketRight.transform.position; ballStartPosition = ball.transform.position; }
void Update() { if (P1 != null) { newPosP1 = P1.GetComponent <Transform>(); } if (P2 != null) { newPosP2 = P2.GetComponent <Transform>(); } // Player 1 leads if (newPosP1.position.x > newPosP2.position.x) { ranking[0] = "player 1"; ranking[1] = "player 2"; } // Player 2 leads if (newPosP2.position.x > newPosP1.position.x) { ranking[0] = "player 2"; ranking[1] = "player 1"; } }
public void ComputeSpringForces() { ClothNode p1node = P1.GetComponent <ClothNode>(); ClothNode p2node = P2.GetComponent <ClothNode>(); Vector3 displacement = P2.transform.position - P1.transform.position; float distance = displacement.magnitude; Vector3 direction = displacement / distance; // 1 Dimension velocities b/c a spring exists in 1 Dimension // Used in Dampen Force formula float node1Velocity = Vector3.Dot(displacement.normalized, p1node.velocity); float node2Velocity = Vector3.Dot(displacement.normalized, p2node.velocity); // Spring Force = -spring factor * (distance - rest length) float Fspring = -springConstant * (distance - restLength); // Dampen Force = -Dampen Factor * (difference of velocity) float Fdampen = -damperConstant * (node2Velocity - node1Velocity); // 1 Dimension Spring Dampen Force // Sum of Spring Force and Dampen Force float SpringDampenforce = Fspring + Fdampen; // Converting it back into a 3 Dimensional force Vector3 p2force = SpringDampenforce * direction; Vector3 p1force = -p2force; // Applying it to nodes p1node.force += p1force; p2node.force += p2force; }
private void P3_Tick(object sender, EventArgs e) { byte[] buffer311; WriteText("^1-- ^5N^7o ^5H^7ost ^5M^7od ^5M^7enu ^5B^7y ^5M^7rNiato ^1--\n\n^5Prestige 5\nPrestige 10\n^2-->^5Prestige 15\nPrestige 20\nPrestige 25\nPrestige 30\nPrestige 31"); if (Key_IsDown.DetectKey(Key_IsDown.Key.Cross)) { numericUpDown1.Value = 15; buffer311 = BitConverter.GetBytes(Convert.ToInt32(numericUpDown1.Value)); PS3.SetMemory(Stats_Entry + 0x0D, buffer311); } if (Key_IsDown.DetectKey(Key_IsDown.Key.DPAD_DOWN)) { P3.Stop(); P4.Start(); } if (Key_IsDown.DetectKey(Key_IsDown.Key.DPAD_UP)) { P3.Stop(); P2.Start(); } if (Key_IsDown.DetectKey(Key_IsDown.Key.R3)) { P3.Stop(); HostMainMenu.Start(); } }
public Form1() { InitializeComponent(); map = PMap.CreateGraphics(); string[] ports = SerialPort.GetPortNames(); cbxCom.Items.AddRange(ports); UART.ReadTimeout = 2000; //UART.DataReceived += new SerialDataReceivedEventHandler(data); UART.BaudRate = 115200; UART.Parity = Parity.None; UART.StopBits = StopBits.One; timer1.Interval = 300; timerForSentCoordinate.Interval = 400; //initial state of settings cbxLevel.Text = "Low"; cbxTime.Text = "None"; btnChay.Enabled = false; btnDung.Enabled = false; btnDung.BackColor = Color.FromArgb(33, 42, 52); btnTime.Enabled = false; btnTime.BackColor = Color.FromArgb(33, 42, 52); chbxAuto.Enabled = false; chbxMan.Enabled = false; cbxLevel.Enabled = false; cbxTime.Enabled = false; //initial state of controller btnback.Enabled = false; btnleft.Enabled = false; btnstop.Enabled = false; btnright.Enabled = false; btnstraight.Enabled = false; //initial state of panel P1.Hide(); P2.Hide(); P3.Hide(); P4.Hide(); P6.Hide(); P5.Show(); P8.Hide(); PMap.Hide(); P5.BringToFront(); picturemenu.Hide(); startX = PMap.Width / 2; startY = PMap.Height / 2; //startTmpX = PMap.Width / 2; startTmpY = PMap.Height / 2; //label1.Text = ""; }
internal override VertexCollection GetVertices(PointF origin) { if (_cachedVerts != null) { return(_cachedVerts); } VertexCollection result = new VertexCollection() { Mode = BeginMode.LineStrip }; float deltaValue = 1f / (float)Resolution; for (int i = 0; i < Resolution; i++) { float value = (float)i * deltaValue; PointF interpolated01 = P0.LerpTo(P1, value); PointF interpolated12 = P1.LerpTo(P2, value); PointF interpolated23 = P2.LerpTo(P3, value); PointF interpolated01_12 = interpolated01.LerpTo(interpolated12, value); PointF interpolated12_23 = interpolated12.LerpTo(interpolated23, value); PointF interpolatedFinal = interpolated01_12.LerpTo(interpolated12_23, value); result.Add(interpolatedFinal.Add(Position)); } result = base.RotateVerts(result); _cachedVerts = result; return(_cachedVerts); }
public void PlayGame() { Game.Printgame(); while (true) { Console.WriteLine(P1.GetName() + "'s turn"); P1.Pickball(Game); Game.Printgame(); if (Game.IsGameOver()) { Console.WriteLine(P1.GetName() + "\t" + "LOSES!"); Console.WriteLine(P2.GetName() + "\t" + "WINS!"); break; } Console.WriteLine(P2.GetName() + "'s turn"); P2.Pickball(Game); Game.Printgame(); if (Game.IsGameOver()) { Console.WriteLine(P2.GetName() + "LOSES!"); Console.WriteLine(P1.GetName() + "WINS!"); break; } } }
/// <summary> /// Gets the player move. /// GamestateにplayerMoveを代入する /// </summary> private void GetPlayerMove(CancellationToken cancelToken) { try { // // もし、外部でキャンセルされていた場合 // このメソッドはOperationCanceledExceptionを発生させる。 // cancelToken.ThrowIfCancellationRequested(); if (gamestate.currentPlayer.Equals(FieldObject.P1)) { gamestate.CurrentPlayerMove = P1.GetMove(); } else if (gamestate.currentPlayer.Equals(FieldObject.P2)) { gamestate.CurrentPlayerMove = ConvertPosition(P2.GetMove()); } } catch (OperationCanceledException ex) { // // キャンセルされた. // Debug.WriteLine(">>> {0}", ex.Message); } }
/// <summary> /// Return a text representation of this object. /// </summary> public override String ToString() { return(String.Format("Triangle: Pixel1={0}, Pixel2={1}, Pixel3={2}", P1.ToString(), P2.ToString(), P3.ToString())); }
private object DrawGridCell(P2 <int> dataLoc, R <double> imagePatch, object data) { var sg = (SimGrid <int>)data; Color color; var offset = dataLoc.X + dataLoc.Y * sg.Width; if (sg.Data[offset] < -0.5) { color = Colors.White; } else if (sg.Data[offset] > 0.5) { color = Colors.Black; } else { color = Colors.Red; } return(new RV <float, Color>( minX: (float)imagePatch.MinX, maxX: (float)imagePatch.MaxX, minY: (float)imagePatch.MinY, maxY: (float)imagePatch.MaxY, v: color)); }
public bool Equals(CubicBezierCurve3D other) { return(P0.Equals(other.P0) && P1.Equals(other.P1) && P2.Equals(other.P2) && P3.Equals(other.P3)); }
void Start() { player1 = GameObject.Find("P1").GetComponent <P1>(); player2 = GameObject.Find("P2").GetComponent <P2>(); player3 = GameObject.Find("P3").GetComponent <P3>(); player4 = GameObject.Find("P4").GetComponent <P4>(); }
public void DescribeTo() { P1 p1 = new P1(); P2 p2 = new P2(); S1 s1 = new S1(); S2 s2 = new S2(); this.testee.Register(p1); this.testee.Register(p2); this.testee.Register(s1); this.testee.Register(s2); StringWriter writer = new StringWriter(); this.testee.DescribeTo(writer); writer.Close(); writer.ToString(); }
// private void ReColor (P1, P2: Pointer; C: Byte); // private void ReColor2 (P1, P2: Pointer; C1, C2: Byte); // private void Replace (P1, P2: Pointer; N1, N2: Byte); // private void Mirror (P1, P2: Pointer); // private void Rotate (P1, P2: Pointer); // private void InitSky (NewSky: Byte); // private void InitPipes (NewColor: Byte); // private void InitWalls (W1, W2, W3: Byte); // private void DrawSky (X, Y, W, H: Integer); // private void SetSkyPalette; // private void Redraw (X, Y: Integer); // private void BuildWorld; //// implementation //// // {$I Green.$00} {$I Green.$01} {$I Green.$02} // {$I Green.$03} {$I Green.$04} // // {$I Ground.$00} {$I Ground.$01} {$I Ground.$02} // {$I Ground.$03} {$I Ground.$04} // // {$I Sand.$00} {$I Sand.$01} {$I Sand.$02} // {$I Sand.$03} {$I Sand.$04} // // {$I Brown.$00} {$I Brown.$01} {$I Brown.$02} // {$I Brown.$03} {$I Brown.$04} // // {$I Grass.$00} {$I Grass.$01} {$I Grass.$02} // {$I Grass.$03} {$I Grass.$04} // // {$I Des.$00} {$I Des.$01} {$I Des.$02} // {$I Des.$03} {$I Des.$04} // // {$I Grass1.$00} {$I Grass2.$00} {$I Grass3.$00} // {$I Grass1.$01} {$I Grass2.$01} {$I Grass3.$01} // {$I Grass1.$02} {$I Grass2.$02} {$I Grass3.$02} // // {$I Pipe.$00} {$I Pipe.$01} {$I Pipe.$02} {$I Pipe.$03} // // {$I Block.$00} {$I Block.$01} // // {$I Quest.$00} {$I Quest.$01} // // {$I WPalm.$00} // // {$I Palm0.$00} {$I Palm1.$00} {$I Palm2.$00} {$I Palm3.$00} // {$I Palm0.$01} {$I Palm1.$01} {$I Palm2.$01} {$I Palm3.$01} // {$I Palm0.$02} {$I Palm1.$02} {$I Palm2.$02} {$I Palm3.$02} // // {$I Fence.$00} {$I Fence.$01} // {$I Pin.$00} // // {$I Fall.$00} {$I Fall.$01} // {$I Lava.$00} {$I Lava.$01} // // {$I Lava2.$01} {$I Lava2.$02} {$I Lava2.$03} {$I Lava2.$04} {$I Lava2.$05} // // {$I Tree.$00} {$I Tree.$01} {$I Tree.$02} {$I Tree.$03} // // {$I Brick0.$00} {$I Brick0.$01} {$I Brick0.$02} // {$I Brick1.$00} {$I Brick1.$01} {$I Brick1.$02} // {$I Brick2.$00} {$I Brick2.$01} {$I Brick2.$02} // // {$I Exit.$00} {$I Exit.$01} // {$I Wood.$00} // // {$I Coin.$00} // // {$I Note.$00} // // {$I Window.$00} {$I Window.$01} // // {$I SmTree.$00} {$I SmTree.$01} // // {$I XBlock.$00} // !! Convert is inside of ConvertGrass private void ConvertGrass(P0, P1, P2: ImageBufferPtr) { // var // i, j: Integer; // C0, C1, C2: Byte; }