示例#1
0
        public float GetGroundLevel(float yPosition)
        {
            float offset      = yPosition - mapPosition.y;
            float groundLevel = maxHeight * Utilities.GetRatioP1P2(offset, 0, length);

            return(groundLevel);
        }
示例#2
0
        public void UpdateHideText()
        {
            float       kTimeTextShown = 4.5f;
            const float kWaitForAard   = 1.0f;

            if (currentText == 2)
            {
                kTimeTextShown = 6.5f;
            }

            if (currentText == ((int)Enum.kCTNumTexts - 1))
            {
                kTimeTextShown = 6.5f;
            }

            if (currentText == 2)
            {
                if (timeSinceText >= (kTimeTextShown - kAardFadeTime))
                {
                    aardmanAlpha = 1.0f - Utilities.GetRatioP1P2(timeSinceText, (kTimeTextShown - kAardFadeTime), kTimeTextShown);
                }
                else if (timeSinceText < kAardFadeTime + kWaitForAard)
                {
                    aardmanAlpha = Utilities.GetRatioP1P2(timeSinceText, kWaitForAard, kAardFadeTime + kWaitForAard);
                }
            }

            if (timeSinceText >= kTimeTextShown)
            {
                this.HideThisText();
                state         = CreditsTextState.kStateHidingLastText;
                timeSinceText = 0.0f;
            }
        }
示例#3
0
        public float GetRightEdgeP1(float inZ, float inY)
        {
            float ratio   = Utilities.GetRatioP1P2(inZ, 0.0f, height);
            float outEdge = (bottomRightGround.x * (1.0f - ratio)) + (bottomRightRoof.x * ratio);

            return(outEdge);
        }
示例#4
0
        public void UpdateSpeed()
        {
            if (boostTimer > 0.0f)
            {
                boostTimer -= Constants.kFrameRate;
                if (boostTimer <= 0.0f)
                {
                    boostPower = 0.0f;
                }
            }

            this.UpdateCurrentElasticity();
            currentSpeed  = baseSpeed + elasticity + myPig.GetWhiteStarExtraSpeed() + boostPower;
            currentSpeed *= myPig.GetSpeedMultiplier();
            const float kMinTurnSizeForSpeedReduction  = 0.02f;
            const float kMaxTurnSizeForSpeedReduction  = 0.08f;
            const float kMaxSpeedReductionForCornering = 0.9f;
            float       turnSize = Utilities.GetABS(myPig.moveAngle - myPig.prevMoveAngle);

            if (turnSize > kMinTurnSizeForSpeedReduction)
            {
                const float kMinCurrentSpeedForSpeedReduction = 8.0f;
                const float kMaxCurrentSpeedForSpeedReduction = 16.0f;
                float       currentSpeedMultiplier            = Utilities.GetRatioP1P2(myPig.GetDistanceLastFrame(), kMinCurrentSpeedForSpeedReduction,
                                                                                       kMaxCurrentSpeedForSpeedReduction);
                float reductionMultiplier = Utilities.GetRatioP1P2(turnSize, kMinTurnSizeForSpeedReduction, kMaxTurnSizeForSpeedReduction);
                currentSpeed -= (currentSpeed * kMaxSpeedReductionForCornering * reductionMultiplier * currentSpeedMultiplier);
            }
        }
示例#5
0
        public void UpdateGreenAntScreen()
        {
            Particle.ParticleInfo info = new Particle.ParticleInfo();
            info.startPosition = Utilities.CGPointMake(160, 140);
            info.velocity      = Utilities.CGPointMake(0, 1);
            timer += Constants.kFrameRate;
            const float kSpinTime = 2.0f;

            if (timer >= kSpinTime)
            {
                timer -= kSpinTime;
            }

            float radians = Utilities.GetRatioP1P2(timer, 0, kSpinTime) * Constants.TWO_PI * 4.0f;
            float wx      = 3.0f;

            info.velocity = Utilities.CGPointMake((float)(Math.Cos(radians) * wx), (float)(Math.Sin(radians) * wx));
            const float kSideSideTime = 10.0f;

            timer2 += Constants.kFrameRate;
            if (timer2 >= kSideSideTime)
            {
                timer2 = 0.0f;
            }

            info.startPosition.x = 50.0f + (220.0f * Utilities.GetCosInterpolationP1P2(timer2, 0, kSideSideTime));
            for (int i = 0; i < 2; i++)
            {
                Particle particle;
                bool     isAdditive = false;
                if (Utilities.GetRand(9) == 0)
                {
                    particle   = (ParticleSystemRoss.Instance()).GetNextFreeParticleP1(ParticleList.t_AdditiveInFrontOfPlayer, "rainbowstars");
                    isAdditive = true;
                }
                else
                {
                    particle = (ParticleSystemRoss.Instance()).GetNextFreeParticleP1(ParticleList.t_AfterEverything, "rainbowstars");
                }

                if (particle != null)
                {
                    if (i == 1)
                    {
                        info.startPosition.x = 320.0f - info.startPosition.x;
                        info.velocity.x      = -info.velocity.x;
                    }

                    particle.Launch_GreenAntScreen(info);
                    particle.SetIsAdditive(isAdditive);
                }
            }

            if (timer >= 2)
            {
            }

            timer += 0.02f;
        }
        bool AVUpdateFade(int soundId)
        {
            if (delay[soundId] > 0)
            {
                delay[soundId] -= Constants.kFrameRate;
                return(false);
            }

            if (fadeTimer[soundId] == 0)
            {
                if (fadingIn[soundId] == (int)Enum.kAVPlayAndFade_In)
                {
                    this.AVPlaySound(soundId);
                }
            }

            fadeTimer[soundId] += Constants.kFrameRate;
            if (fadeTimer[soundId] < fadeTime[soundId])
            {
                float volume;
                if ((fadingIn[soundId] == (int)Enum.kAVFade_In) || (fadingIn[soundId] == (int)Enum.kAVPlayAndFade_In))
                {
                    volume = fadeMinimum[soundId] + ((1.0f -
                                                      fadeMinimum[soundId]) * Utilities.GetRatioP1P2(fadeTimer[soundId], 0, fadeTime[soundId]));
                }
                else
                {
                    volume = fadeMinimum[soundId] + ((1.0f - fadeMinimum[soundId]) * (1 - Utilities.GetRatioP1P2(fadeTimer[soundId], 0, fadeTime[soundId])));
                }

                volume *= playVolumeAV[soundId];
                //        (soundAV[soundId]).SetVolume(volume);
            }
            else
            {
                if ((fadingIn[soundId] == (int)Enum.kAVFade_In) || (fadingIn[soundId] == (int)Enum.kAVPlayAndFade_In))
                {
                    //          (soundAV[soundId]).SetVolume(playVolumeAV[soundId]);
                    fadeMinimum[soundId] = 0;
                }
                else
                {
                    if (fadingIn[soundId] == (int)Enum.kAVFade_OutAndStop)
                    {
                        fadingIn[soundId] = (int)Enum.kAVFade_NotFading;
                        this.EndSoundAV(soundId);
                    }
                    else
                    {
                        //      (soundAV[soundId]).SetVolume(0);
                        fadingIn[soundId] = (int)Enum.kAVFade_NotFading;
                    }
                }

                return(true);
            }

            return(false);
        }
        public void PlayHoofSound()
        {
            float distanceToPlayer = Utilities.GetDistanceP1(position, ((Globals.g_world.game).player).position);
            float volume           = 0.3f + (0.5f * (1.0f - Utilities.GetRatioP1P2(distanceToPlayer, 0.0f, 300.0f)));

            volume *= 0.7f;
            (SoundEngine.Instance()).PlayFinchSoundP1((int)Audio.Enum1.kSoundEffect_RunSoftPig1 + whichHoof, volume);
        }
示例#8
0
        public float GetLeftEdgeForBumpP1(float inY, float inZ)
        {
            float ratio        = Utilities.GetRatioP1P2(inZ, 0, kCliffHeight);
            float edgeAtTop    = this.GetLeftEdgeP1(inY, true);
            float edgeAtBottom = this.GetLeftEdgeP1(inY, false);
            float outEdge      = (ratio * edgeAtTop) + ((1.0f - ratio) * edgeAtBottom);

            return(outEdge);
        }
示例#9
0
 public void PlayerBumpedP1(Player inPlayer, float bumpVol)
 {
     if ((int)inPlayer.playerType == (int)PlayerType.kPlayerSheep)
     {
         int thing       = (int)(3.0f * Utilities.GetRatioP1P2(bumpVol, 0.5f, 0.9f));
         int soundChance = 5 - (int)thing;
         if (Utilities.GetRand(soundChance) == 0)
         {
             this.PlayRandomShaunImpact();
         }
     }
     else
     {
     }
 }
        public void UpdateSparkles()
        {
            return;

            const float sparklesSpeed = 0.015f;

            sparklesPosition += sparklesSpeed;
            if (sparklesPosition >= 1)
            {
                sparklesPosition -= 1;
            }

            CGPoint screenPosition;
            CGPoint buttonPosition = zobject.screenPosition;

            if (sparklesPosition < 0.25f)
            {
                float ratio = Utilities.GetRatioP1P2(sparklesPosition, 0, 0.25f);
                screenPosition = Utilities.CGPointMake(buttonPosition.x - 32 + 64 * ratio, buttonPosition.y + 32);
            }
            else if (sparklesPosition < 0.5f)
            {
                float ratio = Utilities.GetRatioP1P2(sparklesPosition, 0.25f, 0.5f);
                screenPosition = Utilities.CGPointMake(buttonPosition.x - 32 + 64, buttonPosition.y + 32 - (64 * ratio));
            }
            else if (sparklesPosition < 0.75)
            {
                float ratio = Utilities.GetRatioP1P2(sparklesPosition, 0.5f, 0.75f);
                screenPosition = Utilities.CGPointMake(buttonPosition.x - 32 + 64 - (64 * ratio), buttonPosition.y + 32 - 64);
            }
            else
            {
                float ratio = Utilities.GetRatioP1P2(sparklesPosition, 0.75f, 1);
                screenPosition = Utilities.CGPointMake(buttonPosition.x - 32, buttonPosition.y + 32 - 64 + (64 * ratio));
            }

            screenPosition.x += (float)(Utilities.GetRand(6) - 3);
            screenPosition.y += (float)(Utilities.GetRand(6) - 3);
            if (Globals.deviceIPad)
            {
                screenPosition.x += 32.0f;
            }

            ParticleSystemRoss.EffectInfo info = new ParticleSystemRoss.EffectInfo();
            info.startPosition = screenPosition;
            info.type          = EffectType.kEffect_SingleSparkle;
            (ParticleSystemRoss.Instance()).AddParticleEffect(info);
        }
示例#11
0
        public void NewTargetPoint()
        {
            CGPoint projectedPosition = myPig.position;
            CGPoint projectedSpeed    = myPig.GetActualSpeed();

            for (int i = 0; i < 5; i++)
            {
                float speedRatio = Utilities.GetRatioP1P2(currentSpeed, 9.0f, 15.0f);
                float speedLagX  = Utilities.SetRatioP1P2(speedRatio, 0.03f, 0.05f);
                float speedLagY  = Utilities.SetRatioP1P2(speedRatio, 0.05f, 0.85f);
                projectedSpeed.x     = projectedSpeed.x + ((desiredSpeed.x - projectedSpeed.x) * speedLagX);
                projectedSpeed.y     = projectedSpeed.y + ((desiredSpeed.y - projectedSpeed.y) * speedLagY);
                projectedPosition.x += projectedSpeed.x;
                projectedPosition.y += projectedSpeed.y;
            }
        }
示例#12
0
        public float GetRightEdgeP1(float inY, bool onTop)
        {
            int[] tileId = new int[5];
            int   x      = (int)(topLeft.x / 64.0f);
            int   y      = (int)(topLeft.y / 64.0f);

            for (int n = 0; n < 5; n++)
            {
                tileId [n] = (((Globals.g_world.game).tileMap).tileGrid).GetTileIdP1(x + n - 1, y) - (int)TileMap.Enum1.kTile_Cliff1 + 1;
            }

            float kFluffBuffer = 18.0f;

            if (onTop)
            {
                kFluffBuffer = 2.0f;
            }

            if (tileId[3] == 9)
            {
                upSlope = true;
                return(kFluffBuffer + bottomRight.x + (inY - topLeft.y));
            }
            else if (tileId[3] == 14)
            {
                float offset = (inY - topLeft.y);
                if (onTop)
                {
                    return(kFluffBuffer + bottomRight.x + 64.0f - (offset));
                }
                else
                {
                    float kHowFar = 36.0f;
                    if (offset < kHowFar)
                    {
                        return(kFluffBuffer + bottomRight.x + 64.0f);
                    }
                    else
                    {
                        float ratio = Utilities.GetRatioP1P2(offset, kHowFar, 64.0f);
                        return(kFluffBuffer + bottomRight.x + 64.0f - (64.0f * ratio));
                    }
                }
            }

            return(kFluffBuffer + bottomRight.x);
        }
        public void PlayHoofSound()
        {
            float distanceToPlayer = Utilities.GetABS(((Globals.g_world.game).player).position.y - position.y);
            float volume           = 0.3f + (0.3f * (1.0f - Utilities.GetRatioP1P2(distanceToPlayer, 0.0f, 300.0f)));
            bool  playIt           = true;

            if (((Globals.g_world.game).gameState == GameState.e_ShowResultsWin) || ((Globals.g_world.game).gameState == GameState.e_ShowResultsLoseToPiggy
                                                                                     ))
            {
                if ((Globals.g_world.game).stateTimer > 2.4f)
                {
                    playIt = false;
                }
            }

            if (playIt)
            {
                Globals.g_world.PlayFinchSoundWithPositionP1P2(hoofSoundId + whichHoof, volume, position);
            }
        }
示例#14
0
        public void Update()
        {
            if ((int)type == (int)BarType.e_MovingObject)
            {
                float ratio = Utilities.GetRatioP1P2(displayFillLevel, 0, fillMaximum);
                position = Utilities.GetPositionBetweenP1P2(ratio, startPosition, endPosition);
                zobject.SetScreenPosition(position);
                zobject.Update();
            }

            if (state != ZbarStateEnum.kZbarState_Shown)
            {
                {
                    state = ZbarStateEnum.kZbarState_Shown;
                }
            }
            else
            {
                displayFillLevel = displayFillLevel + ((fillLevel - displayFillLevel) * 0.2f);
            }
        }
示例#15
0
        public void UpdatePlayerSpeed()
        {
            float speedRatio = Utilities.GetRatioP1P2(currentSpeed, 5.0f, 20.0f);
            float speedLagX  = Utilities.SetRatioP1P2(speedRatio, 0.08f, 0.2f);
            float speedLagY  = Utilities.SetRatioP1P2(speedRatio, 0.05f, 0.85f);

            if (differentAccelerationTimer > 0.0f)
            {
                speedLagX = 0.03f;
                speedLagY = differentAcceleration;
                differentAccelerationTimer -= Constants.kFrameRate;
            }

            CGPoint newSpeed;

            newSpeed.x = myPig.GetSpeed().x + ((desiredSpeed.x - myPig.GetSpeed().x) * speedLagX);
            float maxXSpeed = 10.0f;

            if (newSpeed.x > maxXSpeed)
            {
                newSpeed.x = maxXSpeed;
            }
            else if (newSpeed.x < -maxXSpeed)
            {
                newSpeed.x = -maxXSpeed;
            }

            newSpeed.y = myPig.GetSpeed().y + ((desiredSpeed.y - myPig.GetSpeed().y) * speedLagY);
            if (skidding)
            {
                myPig.SetSpeedFromRacingBrain(skidDirection);
                skidDirection.x += skidAcceleration.x;
                skidDirection.y += skidAcceleration.y;
            }
            else
            {
                myPig.SetSpeedFromRacingBrain(newSpeed);
            }
        }
示例#16
0
        public void GatesFlyOff()
        {
            if ((((Globals.g_world.game).GetGate(idGate[0])).startingState == StartingGateState.e_Open) && (((Globals.g_world.game).GetGate(idGate[0])).state ==
                                                                                                            StartingGateState.e_Open))
            {
                for (int i = 0; i < numGates; i++)
                {
                    ((Globals.g_world.game).GetGate(idGate[i])).Close();
                }

                float distFromLine = yMapPosition - ((Globals.g_world.game).player).position.y;
                float volume       = 1 - Utilities.GetRatioP1P2(distFromLine, 0, 600);
                (SoundEngine.Instance()).PlayFinchSoundP1((int)Audio.Enum1.kSoundEffect_GateClose, volume);
            }
            else if ((((Globals.g_world.game).GetGate(idGate[0])).startingState == StartingGateState.e_Closed) && (((Globals.g_world.game).GetGate(idGate[0])).
                                                                                                                   state == StartingGateState.e_Closed))
            {
                for (int i = 0; i < numGates; i++)
                {
                    ((Globals.g_world.game).GetGate(idGate[i])).Open();
                }
            }
        }
示例#17
0
        public void UpdateCurrentElasticity()
        {
            #if RUN_AND_RECORD_PIG_TIMES
            return;
            #endif

            #if CAMERA_FOLLOW_PIGGY
            return;
            #endif

            const int kNumFramesBeforeRecheckElasticity = 10;
            if (elasticityCounter < kNumFramesBeforeRecheckElasticity)
            {
                elasticityCounter++;
            }
            else
            {
                elasticityCounter = 0;
                float yDiff = ((Globals.g_world.game).player).position.y - myPig.position.y;
                if (yDiff > 0.0f)
                {
                    const float kMinDistanceBehind = 60.0f;
                    const float kMaxDistanceBehind = 600.0f;
                    float       boost = Utilities.GetRatioP1P2(yDiff, kMinDistanceBehind, kMaxDistanceBehind);
                    elasticity = boost * maxCatchup;
                }
                else
                {
                    const float kDistanceOffScreenStartSlowDown   = 200.0f;
                    const float kDistanceOffScreenForFullSlowDown = 400.0f;
                    float       handicap = Utilities.GetRatioP1P2(-yDiff, Globals.g_world.mapObjectAppearDistance + kDistanceOffScreenStartSlowDown, Globals.g_world.
                                                                  mapObjectAppearDistance + kDistanceOffScreenForFullSlowDown);
                    elasticity = handicap * maxSlowdown;
                }
            }
        }
示例#18
0
        public float GetGroundLevel(CGPoint inPos)
        {
            CGPoint offset = Utilities.CGPointMake(inPos.x - topLeftRoof.x, inPos.y - topLeftRoof.y);

            if ((int)type == (int)BuildingType.kBuilding_SideShed)
            {
                float kShedMaxHeight = height;
                float kShedMinHeight = height - 9.0f;
                if ((inPos.x > bottomRightRoof.x) || (inPos.x < topLeftRoof.x))
                {
                    return(0.0f);
                }
                else if (inPos.y > bottomRightRoof.y)
                {
                    return(0.0f);
                }
                else
                {
                    float distanceToPeak = 160.0f;
                    if (offset.y < distanceToPeak)
                    {
                        float ratio       = Utilities.GetRatioP1P2(offset.y, 0, distanceToPeak);
                        float extraHeight = (ratio * (kShedMaxHeight - kShedMinHeight));
                        return(kShedMinHeight + extraHeight);
                    }
                    else
                    {
                        float distanceToEnd = bottomRightRoof.y - topLeftRoof.y;
                        float ratio         = 1.0f - Utilities.GetRatioP1P2(offset.y, distanceToPeak, distanceToEnd);
                        float extraHeight   = (ratio * (kShedMaxHeight - kShedMinHeight));
                        return(kShedMinHeight + extraHeight);
                    }
                }
            }
            else if ((int)type == (int)BuildingType.kBuilding_Barn)
            {
                if ((inPos.x > bottomRightRoof.x) || (inPos.x < topLeftRoof.x))
                {
                    return(0.0f);
                }
                else if (inPos.y > bottomRightRoof.y)
                {
                    return(0.0f);
                }
                else
                {
                    return(height);
                }
            }
            else if ((int)type == (int)BuildingType.kBuilding_House)
            {
                if ((inPos.x > bottomRightRoof.x) || (inPos.x < topLeftRoof.x))
                {
                    return(0.0f);
                }
                else if (inPos.y > bottomRightRoof.y)
                {
                    return(0.0f);
                }
                else
                {
                    return(height);
                }
            }
            else if (((int)type == (int)BuildingType.kBuilding_Skip) || ((int)type == (int)BuildingType.kBuilding_Tent))
            {
                if ((inPos.x > bottomRightRoof.x) || (inPos.x < topLeftRoof.x))
                {
                    return(0.0f);
                }
                else if (inPos.y > bottomRightRoof.y)
                {
                    return(0.0f);
                }
                else
                {
                    return(height);
                }
            }

            Globals.Assert(false);
            return(0.0f);
        }
 public void SetFingerPosition(CGPoint pos)
 {
     fingerPosition = pos;
     maxDiffY       = 50.0f + (40.0f * (Utilities.GetRatioP1P2(pos.y, 150.0f, 320.0f)));
 }
示例#20
0
        public void StartEffect_DustCloudTrail(ParticleSystemRoss.EffectInfo info)
        {
            Particle.ParticleInfo pInfo = new Particle.ParticleInfo();
            float minDustSpeed;

            if (Globals.g_world.artLevel == 0)
            {
                minDustSpeed = 6.5f;
            }
            else
            {
                minDustSpeed = 4.5f;
            }

            if (player.playerType != (int)PlayerType.kPlayerSheep)
            {
                pInfo.alphaStart = 0.05f + (0.4f * Utilities.GetRatioP1P2(player.GetDistanceLastFrame(),
                                                                          minDustSpeed, 12.0f));
            }
            else
            {
                pInfo.alphaStart = 0.1f + (0.52f * Utilities.GetRatioP1P2(player.GetDistanceLastFrame(), minDustSpeed, 12.0f));
            }

            if (pInfo.alphaStart < 0.3f)
            {
                state = EffectState.e_Inactive;
                return;
            }

            Particle particle = (ParticleSystemRoss.Instance()).GetNextFreeParticleP1(ParticleList.t_BeforePlayer, "dust cloud trail");

            if (particle != null)
            {
                Particle.ParticleInfo info2 = new Particle.ParticleInfo();
                info2.isAdditive       = false;
                info2.type             = ParticleType.kParticle_Generic;
                info2.texture[0]       = (Globals.g_world.game).GetTexture(TextureType.kTexture_BoostExplosion);
                info2.startPosition    = player.GetPosition();
                info2.startPosition.x += ((float)(Utilities.GetRand(30))) - 15;
                info2.startPosition.y += ((float)(Utilities.GetRand(30))) - 15;
                info2.startPosition.x -= player.GetActualSpeed().x;
                info2.startPosition.y -= player.GetActualSpeed().y;
                info2.velocity         = Utilities.CGPointMake(player.GetActualSpeed().x * 0.5f, player.GetActualSpeed().y * 0.5f);
                info2.rotationSpeed    = 0.2f;
                info2.alphaStart       = pInfo.alphaStart;
                if (Globals.g_world.artLevel == 2)
                {
                    if (((Globals.g_world.game).lBuilder).currentScene == (int)SceneType.kSceneMud)
                    {
                        info2.alphaSpeed = 0.014f;
                    }
                    else
                    {
                        info2.alphaSpeed = 0.012f;
                    }
                }
                else if (Globals.g_world.artLevel == 1)
                {
                    info2.alphaSpeed = 0.015f;
                }
                else
                {
                    if ((Globals.g_world.game).numPlayersOnScreen >= 3)
                    {
                        info2.alphaSpeed = 0.04f;
                    }
                    else
                    {
                        info2.alphaSpeed = 0.0225f;
                    }
                }

                if (((Globals.g_world.game).lBuilder).currentScene == (int)SceneType.kSceneIce)
                {
                    if (Globals.g_world.artLevel == 2)
                    {
                        info2.alphaSpeed = 0.007f;
                    }
                }

                if (((Globals.g_world.game).lBuilder).currentScene == (int)SceneType.kSceneMud)
                {
                    if (Globals.g_world.artLevel != 0)
                    {
                        info2.alphaStart *= 1.65f;
                        info2.alphaSpeed *= 1.65f;
                    }
                }

                info2.scaleSpeed = -0.05f; //-1.0f * 0.05 ... //Globals.g_world.GetRotationScaleForShorts(-1.0f);
                info2.scaleStart = 1.0f;
                particle.Launch_SingleParticle(info2);
                particle.SetAtlasAndSubTextureId(Globals.g_world.GetAtlas(AtlasType.kAtlas_ParticlesScene), 0);
                particle.SetRotationScale(Globals.g_world.GetRotationScaleForShorts(45.1f));
                if (Globals.deviceIPad)
                {
                    float rotScale = (Globals.g_world.GetAtlas(AtlasType.kAtlas_ParticlesScene)).GetSubTextureRotationScale(particle.subTextureId);
                    particle.SetRotationScale(rotScale);
                }
                particle.SetIsAdditive(false);
            }

            state = EffectState.e_Inactive;
        }
示例#21
0
        public void Update(ZRMUpdateData inData)
        {
            int[]   realRacePos      = new int[(int)Enum.kMaxNumTeams];
            float[] tempRacePosition = new float[(int)Enum.kMaxNumTeams];
            for (int team = 0; team < numTeams; team++)
            {
                realRacePos [team]             = (int)inData.racePos [team];
                markerPosition [team]          = Utilities.GetRatioP1P2(realRacePos [team], raceFrom, raceTo);
                overTakeThisFrame [team]       = false;
                overTakeThisFramePlayer [team] = false;
            }

            if (numTeams > 1)
            {
                float[] inFrontBy     = new float[(int)Enum.kMaxNumTeams];
                float[] inFrontByReal = new float[(int)Enum.kMaxNumTeams];
                for (int playerPair = 0; playerPair < (numTeams - 1); playerPair++)
                {
                    int frontPlayer  = playerPosition[playerPair];
                    int behindPlayer = playerPosition[playerPair + 1];
                    inFrontBy[playerPair]     = markerPosition[frontPlayer] - markerPosition[behindPlayer];
                    inFrontByReal[playerPair] = realRacePos[frontPlayer] - realRacePos[behindPlayer];
                }

                for (int i = 0; i < numTeams - 1; i++)
                {
                    markerPosition[playerPosition[i + 1]] -= (markerSize * ((float)(i + 1)));
                }

                int behindPlayer8 = playerPosition[numTeams - 1];
                if (markerPosition[behindPlayer8] < 0.0f)
                {
                    float offBottomBy = -markerPosition[behindPlayer8];
                    for (int i = 0; i < (numTeams - 1); i++)
                    {
                        markerPosition[playerPosition[i]]  += offBottomBy;
                        tempRacePosition[playerPosition[i]] = markerPosition[playerPosition[i]];
                    }

                    markerPosition[behindPlayer8]   = 0.0f;
                    tempRacePosition[behindPlayer8] = markerPosition[behindPlayer8];
                }
                else
                {
                    for (int i = 0; i < numTeams; i++)
                    {
                        tempRacePosition[i] = markerPosition[i];
                    }
                }

                for (int playerPair = 0; playerPair < (numTeams - 1); playerPair++)
                {
                    int frontPlayer  = playerPosition[playerPair];
                    int behindPlayer = playerPosition[playerPair + 1];
                    if ((inFrontByReal[playerPair] <= overtakeDistance) && (playerState[behindPlayer] == RMPlayerState.kRMPlayer_Free) && (playerState[
                                                                                                                                               frontPlayer] == RMPlayerState.kRMPlayer_Free))
                    {
                        this.StartOvertakeP1(behindPlayer, frontPlayer);
                    }

                    if (overTakingTimer[behindPlayer] > 0.0f)
                    {
                        overTakingTimer[behindPlayer] -= Constants.kFrameRate;
                        float ratio = 1.0f - Utilities.GetRatioP1P2(overTakingTimer[behindPlayer], 0.0f, overTakeTime);
                        tempRacePosition[behindPlayer] += ratio * markerSize;
                        tempRacePosition[frontPlayer]  -= ratio * markerSize;
                        if (overTakingTimer[behindPlayer] <= 0.0f)
                        {
                            int pos = playerPosition[playerPair];
                            playerPosition[playerPair]     = playerPosition[playerPair + 1];
                            playerPosition[playerPair + 1] = pos;
                            playerState[frontPlayer]       = RMPlayerState.kRMPlayer_Free;
                            playerState[behindPlayer]      = RMPlayerState.kRMPlayer_Free;
                            markerPosition[behindPlayer]  += markerSize;
                            markerPosition[frontPlayer]   -= markerSize;
                        }
                    }
                }
            }
            else
            {
                tempRacePosition[0] = markerPosition[0];
            }

            for (int team = 0; team < numTeams; team++)
            {
                CGPoint markerScreenPos = Utilities.CGPointMake(0, 0);
                if (useLocator)
                {
                }
                else
                {
                    markerScreenPos = Utilities.GetPositionBetweenP1P2(tempRacePosition[playerPosition[team]], raceMarkerStartPos, raceMarkerFinishPos);
                }

                int displayPos = team;
                if (playerState[playerPosition[team]] == RMPlayerState.kRMPlayer_Overtaking)
                {
                    displayPos -= 1;
                }
                else if (playerState[playerPosition[team]] == RMPlayerState.kRMPlayer_BeingOvertaken)
                {
                    displayPos += 1;
                }

                (pMarker[playerPosition[team]]).SetScreenPosition(markerScreenPos);
                (pMarker[playerPosition[team]]).Update();
            }
        }
示例#22
0
        public float GetTopEdge(float inZ)
        {
            float ratio = Utilities.GetRatioP1P2(inZ, 0.0f, height);

            return((topLeftGround.y * (1.0f - ratio)) + (topLeftRoof.y * ratio));
        }
示例#23
0
        public float GetBottomEdge(float inZ)
        {
            float ratio = Utilities.GetRatioP1P2(inZ, 0.0f, height);

            return((bottomRightGround.y * (1.0f - ratio)) + (bottomRightRoof.y * ratio));
        }