private async void Fireball_MessageReceived(Sprite me, Sprite.MessageReceivedArgs what) { if (what.message == "fire" && !me.Visible) { me.SetPosition(Dark.Position); me.SetRotationStyle(Sprite.RotationStyle.AllAround); me.PointTowards(Player.Position); me.Show(); int i = 60; while (i-- > 0 && Running) { await Delay(0.1); me.Move(20); if (me.IsTouching(Player)) { await Delay(0.25); break; } if (me.IsTouchingEdge()) { break; } } me.Hide(); } }
private void Player_MessageReceived(Sprite me, Sprite.MessageReceivedArgs what) { if (what.message == "hit" && !invincible && !lethal) { invincible = true; me.PlaySound("09/3.wav"); --PlayerHP.Value; Task.Run(async() => { for (int i = 10; i > 0; i--) { me.ReduceOpacityBy(0.1); await Delay(0.05); } for (int i = 10; i > 0; i--) { me.ReduceOpacityBy(-0.1); await Delay(0.05); } invincible = false; }); if (PlayerHP.Value <= 0) { Broadcast("lose"); } } }
private void Neo_Cat_MessageReceived(Sprite me, Sprite.MessageReceivedArgs what) { if (what.message == "start") { me.SetCostume("04/7.png"); me.Show(); } else if (what.message == "oh") { Task.Run(async() => { if (Chances.Value > 0) { me.Say("Oh no!!"); await Delay(0.5); me.Say(); } else { me.Say("Try again..."); } }); } else if (what.message == "win") { me.Say("WINNER!!"); } }
private void Pillar_MessageReceived(Sprite me, Sprite.MessageReceivedArgs what) { if (what.message == "update") { var top = me.Variable["top"] as Sprite; var x_before = me.GetPosition().X; top.ChangeXby(-5); var x = me.ChangeXby(-5); if (x < Player.Position.X && x_before >= Player.Position.X) { ++Score.Value; } if (x < LeftEdge - 100) { me.MessageReceived -= Pillar_MessageReceived; me.Destroy(); top.Destroy(); } if (me.IsTouching(Player) || top.IsTouching(Player)) { Broadcast("gameover"); } } }
private async void Keeper_MessageReceived(Sprite me, Sprite.MessageReceivedArgs what) { // Figure out the positions of the net, and use that for // where to roam the keeper var top = Net.Position.Y + Net.CostumeSize.Height / 3; var bottom = Net.Position.Y - Net.CostumeSize.Height / 3; var center = Net.Position.Y; var left = Net.Position.X - Net.CostumeSize.Width / 2; var right = Net.Position.X + Net.CostumeSize.Width / 2; if (what.message == "shoot") { await me.Glide(0.5, new Point(Random(left, right), Random(bottom, top))); } if (what.message == "reset") { var start = me.GetVariable <Point>("start"); me.SetPosition(start); } if (what.message == "win") { me.Say("Great job!"); } if (what.message == "lose") { me.Say("Try again!"); } }
private void Player_MessageReceived(Sprite me, Sprite.MessageReceivedArgs what) { if (what.message == "gameover") { Running = false; Player.Say("Game over!"); } }
private void Ball_MessageReceived(Sprite me, Sprite.MessageReceivedArgs what) { if (what.message == "reset") { me.Say(); me.SetSize(1.0); me.SetVariable <Boolean>("ready", true); var start = me.GetVariable <Point>("start"); me.SetPosition(start); } }
private void Bullseye_MessageReceived(Sprite me, Sprite.MessageReceivedArgs what) { if (what.message == "shoot") { me.Hide(); } if (what.message == "reset") { me.Show(); } }
private void Banner_MessageReceived(Sprite me, Sprite.MessageReceivedArgs what) { if (what.message == "win") { me.SetCostume("09/4.png"); me.Show(); Running = false; } if (what.message == "lose") { me.SetCostume("09/16.png"); me.Show(); Running = false; } }
private void Virus_MessageReceived(Sprite me, Sprite.MessageReceivedArgs what) { if (what.message == "start") { me.SetCostumes("04/V.png", "04/I.png", "04/R.png", "04/U.png", "04/S.png"); me.SetPosition(RightEdge, 0); me.PointTowards(Neo_Cat.Position); me.SetRotationStyle(Sprite.RotationStyle.DoNotRotate); me.Show(); Task.Run(async() => { while (Running) { await Delay(0.3); me.NextCostume(); } while (true) { if (IsGamePadButtonPressed(GamepadButtons.Menu)) { GoBack(); } await Delay(0.1); } }); Task.Run(async() => { var deadly = true; while (Running) { if (me.IsTouching(Neo_Cat)) { me.PointInDirection(Random(-45, 45)); Score.Value++; if (Score.Value >= 30) { Sprite.Broadcast("win"); Running = false; } me.Move(100); } else if ((me.IsTouching(Server1) || me.IsTouching(Server2)) && deadly) { deadly = false; Sprite.Broadcast("oh"); Chances.Value--; if (Chances.Value <= 0) { Running = false; Sprite.Broadcast("lose"); } var ignore = Task.Run(async() => { await Delay(1.0); deadly = true; }); } me.Move(30); await Delay(0.075); me.IfOnEdgeBounce(); } me.Hide(); }); } }