public void ProcessKnockOut(HitCatapult knockoutInfo) { // hide the ball and strap this.strapVisible = StrapVisible.Hidden; this.BallVisible = BallVisible.Hidden; this.Disabled = true; // Remove everything except catpault base/prong this.Delegate?.DidBreak(this, knockoutInfo.JustKnockedout, knockoutInfo.Vortex); }
public void OnGrab(CameraInfo cameraInfo) { // this is now always at the center, so it shouldn't be affected by yaw this.baseWorldPosition = this.Base.PresentationNode.WorldPosition; this.firstGrabTime = GameTime.Time; this.playerWorldPosition = cameraInfo.Ray.Position; var ballPosition = this.ComputeBallPosition(cameraInfo); this.rope.GrabBall(ballPosition); this.strapVisible = StrapVisible.Visible; this.BallVisible = BallVisible.Visible; this.AlignCatapult(cameraInfo); // rotate the slingshot before we move it this.AnimateGrab(ballPosition); this.IsPulledTooFar = false; }
public void SetProjectileType(ProjectileType projectileType, SCNNode projectile) { this.Projectile?.RemoveFromParentNode(); this.Projectile = projectile; this.ProjectileType = projectileType; this.projectileScale = projectile.Scale; // the rope adjusts to the radius of the ball var projectilePaddingScale = 1f; nfloat radius = 0f; var temp = SCNVector3.Zero; projectile.GetBoundingSphere(ref temp, ref radius); this.rope.SetBallRadius((float)radius * projectilePaddingScale); // need ball to set a teamID, and then can color with same mechanism //projectile.setPaintColor() // will be made visible and drop when cooldown is exceeded, // this way ball doesn't change suddenly while visible this.BallVisible = BallVisible.Hidden; this.UpdateFakeProjectileVisibility(); }
public void OnLaunch(GameVelocity velocity) { if (this.isGrabbed) { // can't grab again until the cooldown animations play ballCanBeGrabbed = false; // update local information for current player if that is what is pulling the catapult // start the launch animation this.rope.LaunchBall(); // must reset the move to distance 0 before the launch, otherwise it will start a new // stretch sound. this.Delegate?.DidMove(this, 0f, 0f); this.Delegate?.DidLaunch(this, velocity); // set the ball to invisible this.BallVisible = BallVisible.Hidden; // record the last launch time, and enforce a cooldown before ball reappears (need an update call then?) this.lastLaunchTime = GameTime.Time; } }
public void Update() { if (this.Disabled) { this.BallVisible = BallVisible.Hidden; } else { this.rope.UpdateRopeModel(); // ball on the sling will remain invisible until cooldown time exceeded // base this on animation of sling coming back to rest if (this.ballVisible == BallVisible.Hidden) { // make sure cooldown doesn't occur starting the ball animation // until a few seconds after loading the level if (this.lastLaunchTime == 0d) { this.lastLaunchTime = GameTime.Time; } // only allow grabbing the ball after the cooldown animations play (grow + drop) var timeElapsed = GameTime.Time - this.lastLaunchTime; var timeForCooldown = this.properties.CooldownTime - this.properties.GrowAnimationTime - this.properties.DropAnimationTime; if (timeForCooldown < 0.01) { timeForCooldown = 0d; } var startCooldownAnimation = timeElapsed > timeForCooldown; if (startCooldownAnimation) { // show the ball at the ballOrigin, that's in the sling this.BallVisible = BallVisible.Partial; } } this.UpdateCatapultStable(); // Make sure that the ball stays in its place even if the catapult move if (this.ballCanBeGrabbed) { if (this.isGrabbed) { if (this.Projectile == null) { throw new Exception("isGrabbed but has no projectile"); } this.rope.MoveBall(this.Projectile.WorldPosition); } else { if (this.Projectile != null) { this.Projectile.WorldPosition = this.ballOriginInactiveBelow.PresentationNode.WorldPosition; } } } } }