void takeBall(Ball ball) { if(!parrying) { //SoundEffectInstance sound = Assets.getSound("pickup").CreateInstance(); //sound.Pitch = 1f + (G.RNG.Next(-99, -20) * 0.01f); //sound.Play(); Assets.getSound("pickup").Play(0.6f, G.RNG.Next(-25, 25)/100f, 0); } ball.dangerous = false; ball.owned = true; ball.owner = this; this.ball = ball; this.ball.pickedUp(); }
void hitByBall(Ball ball) { if(ball.owner != null && ball.owner.team != team) { hitPoints -= (ball.velocity.Length()) / DAMAGE_DENOM; playHitSound(); hurt = true; throwing = false; parrying = false; velocity.X = ball.velocity.X*10; velocity.Y = ball.velocity.Y*10; play("hurt"); blood.spray(); dropBall(); } }
void hitRumble(Ball ball) { float relativeSpeed = ball.velocity.Length() / MaxFling; float seconds = MathHelper.Lerp(MIN_HIT_SECONDS, MAX_HIT_SECONDS, relativeSpeed); //TODO: FINISH THIS SHIT float big = MathHelper.Lerp(MIN_HIT_POWER, MAX_HIT_POWER, relativeSpeed); float little = MathHelper.Lerp(MIN_HIT_POWER, MAX_HIT_POWER, relativeSpeed); G.DoForSeconds(seconds, () => GamePad.SetVibration(playerIndex, big, little), () => GamePad.SetVibration(playerIndex, 0, 0)); }
void dropBall() { if(ball != null) { flungAtCharge = DROP_CHARGE; ball.Fling(onRight ? 1f : -1f, 0.5f, DROP_CHARGE); //ball.dangerous = false; ball = null; canPickupBall = false; G.state.DoInSeconds(DROP_PICKUP_TIME, () => canPickupBall = true); maxSpeed = MAX_RUN_SPEED; retical.visible = false; } }
void FlingBall() { if(ball != null && !Dead && !parrying) { flungAtCharge = charge; float relativeCharge = (flungAtCharge - minCharge) / (maxCharge - minCharge); if(relativeCharge > 0.99) { ball.throwSound = Assets.getSound("chargedThrow").CreateInstance(); ball.throwSound.Play(); ball.throwSound.Pan = panPosition(); ball.throwSound.Volume = CHARGED_THROW_VOLUME; } else { ball.throwSound = Assets.getSound("throw1").CreateInstance(); ball.throwSound.Play(); ball.throwSound.Pan = panPosition(); ball.throwSound.Pitch = -0.3f + relativeCharge; ball.throwSound.Volume = 0.75f + (relativeCharge / 4f); } Vector2 flingDirection = Vector2.Normalize(retical.Direction); ball.Fling(flingDirection.X, flingDirection.Y, charge); ball = null; play("throw"); throwing = true; animation.reset(); animation.FPS = MIN_THROW_FPS + ((charge / maxCharge) * (MAX_THROW_FPS - MIN_THROW_FPS)); if(charge > DROP_CHARGE) { G.DoForSeconds(0.2f, () => GamePad.SetVibration(playerIndex, (flungAtCharge - minCharge) / (maxCharge - minCharge), 0), () => GamePad.SetVibration(playerIndex, 0, 0)); } } }
void catchBall(Ball ball) { hitPoints += (ball.velocity.Length()) / HEAL_DENOM; playerGlow.flash(); takeBall(ball); }
void blockBall(Ball ball) { }
public void onCollide(Ball ball) { if(!ball.dangerous && this.ball == null && !ball.owned && !throwing && !hurt && !Dead && ball.collectable && canPickupBall) { takeBall(ball); } else if(ball.dangerous && !Dead) { if(ball.owner.team != team) hitRumble(ball); if(ActiveParry && ball.owner.team != team) { if(this.ball == null) { catchBall(ball); } else { blockBall(ball); } } else { hitByBall(ball); } } }
public BallTrail(Ball ball) : base() { this.ball = ball; }
public override void Create() { G.playMusic("GameMusic"); //G.visualDebug = true; Sprite arenaBackground = new Sprite(-G.camera.x, -68 + ARENA_OFFSET_Y - 280); arenaBackground.loadGraphic("arenaBackground", 640, 640); arenaBackground.z = -10; //arenaBackground.screenPositioning = ScreenPositioning.Absolute; add(arenaBackground); Sprite arenaForeground = new Sprite(-G.camera.x, -68 + ARENA_OFFSET_Y); arenaForeground.loadGraphic("arenaForeground", 640, 360); arenaForeground.z = 9999; //arenaForeground.screenPositioning = ScreenPositioning.Absolute; add(arenaForeground); Sprite arenaVignette = new Sprite(0, 0); arenaVignette.loadGraphic("arenaVignette", 640, 360); arenaVignette.z = 10000; arenaVignette.screenPositioning = ScreenPositioning.Absolute; add(arenaVignette); Ball ball = new Ball(); ball = new Ball(ARENA_WIDTH/2 - 30, ARENA_HEIGHT/2 - 30); add(ball); balls.add(ball); ball = new Ball(ARENA_WIDTH/2 + 20, ARENA_HEIGHT/2 - 30); add(ball); balls.add(ball); ball = new Ball(ARENA_WIDTH/2 - 30, ARENA_HEIGHT/2 + 15); add(ball); balls.add(ball); ball = new Ball(ARENA_WIDTH/2 + 20, ARENA_HEIGHT/2 + 15); add(ball); balls.add(ball); balls.Each((b) => { b.addOnMoveCallback(onBallMove); }); teamPlayers.Add(Team.Left, new Group()); teamPlayers.Add(Team.Right, new Group()); //probably want to let people pick their team later teamPlayers[Team.Left].add( new Player(GameTracker.LeftPlayers[0], Team.Left, new Vector2(0, 0), CourtPosition.TopLeft)); teamPlayers[Team.Left].add( new Player(GameTracker.LeftPlayers[1], Team.Left, new Vector2(0, 1), CourtPosition.BottomLeft)); teamPlayers[Team.Right].add( new Player(GameTracker.RightPlayers[0], Team.Right, new Vector2(1, 0), CourtPosition.TopRight)); teamPlayers[Team.Right].add( new Player(GameTracker.RightPlayers[1], Team.Right, new Vector2(1, 1), CourtPosition.BottomRight)); teamPlayers[Team.Left].Each((player) => players.add(player)); teamPlayers[Team.Right].Each((player) => players.add(player)); players.Each((player) => add(player)); hud = new HUD(players); hud.visible = false; add(hud); card = new Card(); add(card); pauseGroup = new PauseGroup(card, onUnPause); add(pauseGroup); GameTracker.RoundSeconds = GameTracker.TotalSeconds; }