private void FrmBallClass_Load(object sender, EventArgs e) { this.DoubleBuffered = true; this.Paint += FrmBallClass_Paint; Random rnd = new Random(); ballMaster = new BouncingBall(this, ClientRectangle.Width / 2, ClientRectangle.Height / 2, rnd.Next(1, 10), rnd.Next(1, 10), rnd.Next(50, 200), new SolidBrush( Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)))); ballMaster2 = new BouncingBall(this, ClientRectangle.Width / 2, ClientRectangle.Height / 2, rnd.Next(1, 10), rnd.Next(1, 10), rnd.Next(50, 200), new SolidBrush( Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)))); draw = new Timer(); draw.Interval = 10; draw.Tick += Draw_Tick; draw.Enabled = true; }
// private bool isPause = false; // Use this for initialization void Awake() { gameManager = GameObject.FindObjectOfType <GameManager>(); GameObject text = GameObject.Find("Pause"); player = GameObject.FindObjectOfType <BouncingBall> (); GameObject score = GameObject.Find("Score"); GameObject bS = GameObject.Find("BestScore"); GameObject powerUps = GameObject.Find("PowerUps"); if (text) { pauseText = text.GetComponent <Text>(); } if (score) { scoreText = score.GetComponent <Text>(); } if (bS) { bestScore = bS.GetComponent <Text>(); bestScore.text = gameManager.bestscore.ToString(); } if (powerUps) { powerUpsText = powerUps.GetComponent <Text> (); } }
void Start() { cam = Camera.main.transform; pillar = GameObject.Find("Pillar").transform; ball = GameObject.Find("Ball").GetComponent <BouncingBall>(); canvas = GameObject.Find("Canvas").transform; totalScoreText = GameObject.Find("FinalScore").GetComponent <Text>(); score = GameObject.Find("Score").GetComponent <Text>(); CircleQueue = new LinkedList <CircleList>(); GameOverUI.SetActive(false); //初始化两个圆环避免开始重复计算分数 CircleQueue.AddLast(GetNewCircle()); curNode = CircleQueue.Last; DropNode = CircleQueue.Last; curNode.Value.GenerateByLevel(level); curNode.Value.transform.position = Vector3.zero; lowestCircleY = curNode.Value.transform.position.y; CircleQueue.AddLast(GetNewCircle()); curNode = CircleQueue.Last; curNode.Value.GenerateByLevel(level); curNode.Value.transform.position = new Vector3(0, lowestCircleY - gap); lowestCircleY = curNode.Value.transform.position.y; }
public void NoOfTimesSeen_WithInvalidHeight_ReturnsNegativeOne() { //act var x = BouncingBall.bouncingBall(-1, 0.5, -2); //assert Assert.That(x, Is.EqualTo(-1)); }
public void NoOfTimesSeen_WithInvalidBounceRate_ReturnsNegativeOne(double h, double bounce, double window) { //act var x = BouncingBall.bouncingBall(h, bounce, window); //assert Assert.That(x, Is.EqualTo(-1)); }
public void NoOfTimesSeen_WithInvalidWindowGreaterThanHeight_ReturnsNegativeOne(double h, double bounce, double window) { //act var x = BouncingBall.bouncingBall(4, 0.5, 5); //assert Assert.That(x, Is.EqualTo(-1)); }
public void NoOfTimesSeen_WithValidParameters2_ReturnsCorrectResult() { //act var x = BouncingBall.bouncingBall(30.0, 0.66, 1.5); //assert Assert.That(x, Is.EqualTo(15)); }
public void CreateProjectile(int playerId, Vector2 position, Vector2 velocity, int projectileType) { Projectile projectile = new BouncingBall(projectileIdGenerator, position, velocity); projectileIdGenerator += 1; this.Projectiles.Add(projectile); NewProjectiles.AddLast(projectile); }
public void Collision_OnCorner() { Projectile projectile = new BouncingBall(0, new Vector2(0, 0), new Vector2(1, 0)); Wall wall = new Wall(new Vector2(-5, 10), new Vector2(4.9f, .1f)); Vector2 collisionPoint = projectile.GetCollisionPoint(wall); AssertAreClose(new Vector2(4.7878675f, 0.21213183f), collisionPoint); }
public void Collision_HeadOn() { Projectile projectile = new BouncingBall(0, new Vector2(0, 0), new Vector2(1, 0)); Wall wall = new Wall(new Vector2(0, 10), new Vector2(0, -10f)); Vector2 collisionPoint = projectile.GetCollisionPoint(wall); AssertAreClose(new Vector2(0, 0), collisionPoint); }
public void Collision_CompleteMiss() { Projectile projectile = new BouncingBall(0, new Vector2(0, 0), new Vector2(1, 0)); Wall wall = new Wall(new Vector2(0, 10), new Vector2(0, 5)); Vector2 collisionPoint = projectile.GetCollisionPoint(wall); Assert.AreEqual(Vector2.MinValue, collisionPoint); }
static void Main(string[] args) { BouncingBall dropTheBall = new BouncingBall(); // test different cases here by changing inputs int result = dropTheBall.bouncingBall(3, 0.66, 1.5); // uncomment to see the result in the console // Console.WriteLine(result); }
private void OnCollisionEnter2D(Collision2D collision) { if (collision.gameObject.tag == "Player") { BouncingBall blobi = collision.gameObject.GetComponent <BouncingBall>(); // Set the color to Red blobi.GetComponent <SpriteRenderer>().color = new Color(1.0f, 0.0f, 0.0f, 1.0f); blobi.canOverJump = true; StartCoroutine(isTimeToDead(0.1f)); } }
public BorderBouncingForm() { // C# doin' his thing InitializeComponent(); // get actual width and height wHeight = ClientSize.Height; wWidth = ClientSize.Width; _grid = new Grid(Width / 30); _bounceBall = new BouncingBall(30, 30, 20, Brushes.Tomato); }
public Vector2 Attract(BouncingBall mover) { var vv = new Vector2(this.loc.X - mover.loc.X, this.loc.Y - mover.loc.Y); var dist = vv.Length(); vv.limit(1); dist = Utils.constrain(dist, 10.0f, 40.0f); var force = (G * mover.mass * this.mass) / (dist * dist); vv *= force; return(vv); }
private void FrmBallClass_Load(object sender, EventArgs e) { this.DoubleBuffered = true; BallColor = Brushes.Red; this.Paint += FrmBallClass_Paint; Ball = new BouncingBall(this.CreateGraphics(), this, 100, 100, 2, 2, 50, BallColor); Draw = new Timer(); Draw.Interval = 10; Draw.Tick += Draw_Tick; Draw.Enabled = true; }
public void Game_PlayerRequestsProjectile() { Game game = TestObjects.BuildFullRunningGame(); Schema.ProjectileCreated projCreated = TestObjects.BuildPlayerCreatesProjectile(new Vector2(5, 6), new Vector2(1, 1), ProjectileType.BouncingBall); game.Players[0].ClientSendToServer(Any.Pack(projCreated)); game.Update(game.LastUpdateTime); Schema.ProjectileCreated sentProjCreatedMessage = game.Players[0].MessageLog.First.Next.Value.Unpack <Schema.ProjectileCreated>(); BouncingBall dummyBouncingBall = new BouncingBall(-1, new Vector2(), new Vector2()); Assert.AreEqual(projCreated.Position, sentProjCreatedMessage.Position); Assert.AreEqual(projCreated.Velocity, sentProjCreatedMessage.Velocity); Assert.AreEqual(projCreated.Type, sentProjCreatedMessage.Type); Assert.AreEqual(dummyBouncingBall.Mass, sentProjCreatedMessage.Mass); Assert.AreEqual(dummyBouncingBall.Radius, sentProjCreatedMessage.Radius); }
/// <summary> /// Checks if the collider caused a trigger. /// </summary> /// <param name="collision"></param> private void OnTriggerEnter2D(Collider2D col) { if (!isCheckPointTouched) { BouncingBall p1 = player.GetComponent <BouncingBall>(); if (p1.level != 1) { gameManager.AddScore(1); } } if (col.gameObject.CompareTag("Player")) { isCheckPointTouched = true; player.GetComponent <BouncingBall>().currentCheckpoint = gameObject; } if (col.gameObject.name.Contains("Lava")) { touchedLava = true; } }
public void Test3() { Assert.Equal(1.5951180154118365, BouncingBall.getPosition(981, 10, 0, 47), 9); }
public void Test6() { Assert.Equal(0.036079462357220954, BouncingBall.getPosition(1000, 10, 10, 50), 9); }
public void CanCreate() { game = new BouncingBall(); game.Should().NotBeNull(); }
public void Test1() { Assert.AreEqual(3, BouncingBall.bouncingBall(3.0, 0.66, 1.5)); }
public void Test1() { Assert.Equal(5.095, BouncingBall.getPosition(981, 10, 0, 1), 9); }
public void Test2() { Assert.AreEqual(15, BouncingBall.bouncingBall(30.0, 0.66, 1.5)); }
public void Test2() { Assert.Equal(6.408564143658009, BouncingBall.getPosition(981, 10, 0, 2), 9); }
public void Test5() { Assert.Equal(0.7952075484286876, BouncingBall.getPosition(981, 10, 8, 47), 9); }
override public BT_Status UpdateAction() { Direction testDir = followPlayer.DetectDirection(transform.position, player.transform.position); switch (testDir) { case Direction.LEFT: mySpriteRend.flipX = false; break; case Direction.RIGHT: mySpriteRend.flipX = true; break; } if (!throwBalls) { transform.position = Vector3.MoveTowards(transform.position, tempTrans.position, Time.deltaTime * 5.0f); if ((tempTrans.position - transform.position).magnitude < 0.1f) { myAnimator.SetBool("KelpieShoot", true); throwBalls = true; //InmortalGo.SetActive(true); } } else { timerAnimation += Time.deltaTime; if (timerAnimation >= 1.25f && !doneThrow) { for (int i = 0; i < numOfBalls; i++) { timerCountBalls = 0; ballsSpawned++; GameObject go = Instantiate(WaterBall); BouncingBall bounce = go.GetComponent <BouncingBall>(); if (bounce != null) { Direction dir; if (transform.position.x > player.transform.position.x) { dir = Direction.LEFT; } else { dir = Direction.RIGHT; } switch (dir) { case Direction.LEFT: Vector3 left = -rightTrans.transform.right; if (i == 0) { bounce.SetDirection(left); } else if (i == 1) { Vector3 newDirUp = Quaternion.AngleAxis(45.0f, Vector3.forward) * left; bounce.SetDirection(newDirUp); } else if (i == 2) { Vector3 newDirDown = Quaternion.AngleAxis(-45.0f, Vector3.forward) * left; bounce.SetDirection(newDirDown); } break; case Direction.RIGHT: Vector3 right = rightTrans.transform.right; if (i == 0) { bounce.SetDirection(right); } else if (i == 1) { Vector3 newDirUp = Quaternion.AngleAxis(45.0f, Vector3.forward) * right; bounce.SetDirection(newDirUp); } else if (i == 2) { Vector3 newDirDown = Quaternion.AngleAxis(-45.0f, Vector3.forward) * right; bounce.SetDirection(newDirDown); } break; } } go.transform.position = transform.position; } doneThrow = true; } else if (timerAnimation >= 2.10f && doneThrow) { myAnimator.SetBool("KelpieShoot", false); doneThrow = false; isFinish = true; InmortalGo.SetActive(false); } } return(BT_Status.RUNNING); }
static void Main(string[] args) { //Console.WriteLine(Math.Log(1.5 / 3.0, 0.66)); Console.WriteLine(BouncingBall.bouncingBall(30.0, 0.66, 1.5)); Console.ReadKey(); }
static void Main(string[] args) { Console.WriteLine(BouncingBall.bouncingBall(3.0, 0.66, 1.5)); Console.ReadKey(); }
public void Test4() { Assert.Equal(6.081311391188509, BouncingBall.getPosition(981, 10, 8, 2), 9); }