public void UpdateSplashingInWater() { timer += player.GetDistanceLastFrame() + 1; const float kTimeBetweenSplashes = 20; if (timer >= kTimeBetweenSplashes) { ParticleList inList; if (player.positionZ < -5.0f) { inList = ParticleList.t_DownInRiver; } else { inList = ParticleList.t_BeforePlayer; } Particle particle = (ParticleSystemRoss.Instance()).GetNextFreeParticleP1(inList, "scal_rip"); if (particle != null) { CGPoint pos = player.position; CGPoint speed = player.GetActualSpeed(); if ((Utilities.GetABS(speed.x) < 0.01f) && (Utilities.GetABS(speed.y) < 0.01f)) { speed = Utilities.CGPointMake(0.0f, 0.0f); } else { speed = Utilities.Normalise(speed); } pos.x = pos.x + (speed.x * 20); pos.y = pos.y + (speed.y * 20); particle.Launch_ScalingRipple(pos); particle.SetAtlasAndSubTextureId(Globals.g_world.GetAtlas(AtlasType.kAtlas_ParticlesScene), 9); } timer -= kTimeBetweenSplashes; } }
public void SetNextTargetPoint() { CGPoint targetPosition; if (dodgingTractor != -1) { targetPosition = dodgingTractorPos; #if DEBUG_DRAW_RACING_LINE inFlockTargetPos = targetPosition; #endif } else { CGPoint lookPosition = myPig.position; lookPosition.y += 120.0f; int inWhichFlock = (Globals.g_world.game).IsInFlock(lookPosition); if (inWhichFlock == -1) { if (inFlock) { inFlock = false; this.SetTargetPointFromHere(300.0f); } targetPosition = Utilities.CGPointMake(racingLine.GetPoint(targetPoint).x, racingLine.GetPoint(targetPoint).y); } else { targetPosition = ((Globals.g_world.game).GetFlock(inWhichFlock)).GetNextMarkerForAI(myPig.position); inFlock = true; #if DEBUG_DRAW_RACING_LINE inFlockTargetPos = targetPosition; #endif } } CGPoint directionVector = Utilities.CGPointMake(targetPosition.x - myPig.position.x, targetPosition.y - myPig.position.y); if ((targetPosition.x != 0.0f) && (targetPosition.y != 0.0f)) { if ((directionVector.x != 0.0f) || (directionVector.y != 0.0f)) { if (myPig.GetActualSpeed().y > 4.0f) { float numFrames = directionVector.y / myPig.GetActualSpeed().y; CGPoint nowPos = myPig.position; CGPoint projectedPosition = Utilities.CGPointMake(nowPos.x + (myPig.GetActualSpeed().x *numFrames), nowPos.y + (myPig.GetActualSpeed().y * numFrames)); float xDiff = targetPosition.x - projectedPosition.x; targetPosition.x += xDiff * 0.75f; #if DEBUG_DRAW_RACING_LINE showTargetPos = targetPosition; #endif directionVector = Utilities.CGPointMake(targetPosition.x - myPig.position.x, targetPosition.y - myPig.position.y); CGPoint normal = Utilities.Normalise(directionVector); desiredSpeed.x = normal.x * currentSpeed; desiredSpeed.y = normal.y * currentSpeed; } else { CGPoint normal = Utilities.Normalise(directionVector); desiredSpeed.x = normal.x * currentSpeed; desiredSpeed.y = normal.y * currentSpeed; } } } else { } }
public void BumpP1(CGPoint newVelocity, Player whoBy) { #if RACE_AS_PIGGY return; #endif if (bumpTimer > 0.0f) { #if NOT_FINAL_VERSION if (whoBy == (Globals.g_world.game).player) { } #endif return; } #if NOT_FINAL_VERSION if (whoBy == (Globals.g_world.game).player) { } #endif CGPoint bumpVelocity = Utilities.CGPointMake(newVelocity.x, newVelocity.y / 6.0f); if ((int)crossingThingType == (int)CrossingThingType.kCrossingThing_Elephant) { bumpMaxDistance = 2.0f * Utilities.GetDistanceP1(Utilities.CGPointMake(0.0f, 0.0f), bumpVelocity); } else if ((int)crossingThingType == (int)CrossingThingType.kCrossingThing_Sheep) { bumpMaxDistance = 20.0f * Utilities.GetDistanceP1(Utilities.CGPointMake(0.0f, 0.0f), bumpVelocity); } else { bumpMaxDistance = 5.0f * Utilities.GetDistanceP1(Utilities.CGPointMake(0.0f, 0.0f), bumpVelocity); } bumpDirection = Utilities.Normalise(bumpVelocity); const float kMaxBumpSameDir = 30.0f; const float kMaxBumpOppDir = 80.0f; float xThing = bumpMaxDistance * bumpDirection.x; if (xSpeed > 0.0f) { if (xThing > kMaxBumpSameDir) { bumpMaxDistance = bumpDirection.x * kMaxBumpSameDir; } else if (xThing < -kMaxBumpOppDir) { bumpMaxDistance = -bumpDirection.x * kMaxBumpOppDir; } } else { if (xThing < -kMaxBumpSameDir) { bumpMaxDistance = -bumpDirection.x * kMaxBumpSameDir; } else if (xThing > kMaxBumpOppDir) { bumpMaxDistance = bumpDirection.x * kMaxBumpOppDir; } } bumpTimer = kCTBumpTime; }
public float BumpP1(CGPoint newVelocity, Player whoBy) { #if RACE_AS_PIGGY return(false); #endif CGPoint bumpVelocity = Utilities.CGPointMake(newVelocity.x, newVelocity.y - myFlock.speed); float powerSqr = Utilities.GetSqrDistanceP1(Utilities.CGPointMake(0.0f, myFlock.speed), newVelocity); if (flockAnimalType == FlockAnimalType.kFlockAnimalShirley) { if (powerSqr > 120.0f) { if (whoBy == (Globals.g_world.game).player) { ((Globals.g_world.frontEnd).profile).QueueAchievement(Profile.Enum2.kAchievement_ShirleyThump); ((Globals.g_world.frontEnd).profile).FlushPendingAchievements(); } } if (powerSqr > 24.0f) { if (bumpTimer <= 0.25f) { (SoundEngine.Instance()).PlayFinchSound((int)Audio.Enum1.kSoundEffect_HitShirley); } } } if (bumpTimer > 0.0f) { return(0.0f); } if (flockAnimalType == FlockAnimalType.kFlockAnimalCow) { bumpMaxDistance = 2.0f * Utilities.GetDistanceP1(Utilities.CGPointMake(0.0f, 0.0f), bumpVelocity); } else if (flockAnimalType == FlockAnimalType.kFlockAnimalSheep) { bumpMaxDistance = 2.0f * Utilities.GetDistanceP1(Utilities.CGPointMake(0.0f, 0.0f), bumpVelocity); } else if (flockAnimalType == FlockAnimalType.kFlockAnimalZebra) { bumpMaxDistance = 3.2f * Utilities.GetDistanceP1(Utilities.CGPointMake(0.0f, 0.0f), bumpVelocity); } else if (flockAnimalType == FlockAnimalType.kFlockAnimalShirley) { bumpMaxDistance = 2.0f * Utilities.GetDistanceP1(Utilities.CGPointMake(0.0f, 0.0f), bumpVelocity); } else { bumpMaxDistance = 5.0f * Utilities.GetDistanceP1(Utilities.CGPointMake(0.0f, 0.0f), bumpVelocity); } bumpDirection = Utilities.Normalise(bumpVelocity); bumpTimer = kBumpTime; return(powerSqr); }
public static CGPoint GetVectorBetweenNormalisedP1(CGPoint point1, CGPoint point2) { CGPoint difference = Utilities.CGPointMake(point2.x - point1.x, point2.y - point1.y); return(Utilities.Normalise(difference)); }