コード例 #1
0
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);
            distTravelled += Body.LinearVelocity.Length();
            if (AsType.UniformScale < 0.69f)
            {
                AsType.UniformScale = JabMath.MoveTowards(AsType.UniformScale, 0.7f, 0.25f);
            }
            else
            {
                AsType.UniformScale = 0.7f;
            }
            if (distTravelled > 32)
            {
                Body.CollisionGroup = 0;
            }

            if (destructionTimer > 0)
            {
                destructionTimer -= gttf(gameTime);
                if (destructionTimer < 0)
                {
                    RaiseFlag(Jabber.Flags.DELETE);


                    Explosion exp = new Explosion(10, 300, 1.0f, 0.7f, scene.World, Position);
                    Body.IgnoreRayCast = true;
                    exp.Initialize(Jabber.BaseGame.Get.Content);
                    exp.Position = Position;
                    scene.AddNode(exp);
                    RaiseFlag(Jabber.Flags.DELETE);
                    Body.IgnoreRayCast = false;

                    AudioQueue.PlayOnce("Sounds/Explode_Chicken");
                }
                else
                {
                    float val = destructionTimer;
                    Colour = new Color(1.0f, val, val, 1.0f);

                    // AsType.UniformScale = (float)Math.Sin(destructionTimer * 5.0f * JabMath.PI) + 1;

                    AsType.UniformScale = JabMath.LinearInterpolate(0.8f, 0.85f, (float)Math.Sin(destructionTimer * 5.0f * JabMath.PI) + 1);
                    DoDimensions        = false;
                    int k = 0;
                }
            }
            if (Body.LinearVelocity.Length() < 0.001f)
            {
                noMoveTimer += gttf(gameTime);
                if (noMoveTimer > 1.0f && destructionTimer < 0)
                {
                    destructionTimer = 1.0f;
                }
            }
            else
            {
                noMoveTimer = 0.0f;
            }
        }
コード例 #2
0
        void SetScale()
        {
            float posx = PosX;

            float targetX = targetAreaPos.X;
            float originX = originPos.X;

            if (posx < originX)
            {
                posx = originX;
            }
            else if (posx > targetX)
            {
                posx = targetX;
            }

            float distBetween = Math.Abs(targetX - originX);

            targetX -= originX;
            posx    -= originX;

            posx /= targetX;

            if (UniformWorldScale > JabMath.LinearInterpolate(scaleAtTarget, scaleAtTarget, posx))
            {
                UniformWorldScale = JabMath.LinearInterpolate(scaleAtTarget, scaleAtTarget, posx);
            }
            else if (UniformWorldScale < maxCamScale)
            {
                UniformWorldScale = JabMath.MoveTowards(UniformWorldScale, maxCamScale, 0.05f, 0.01f);// JabMath.LinearInterpolate(UniformWorldScale, maxCamScale, posx); //maxCamScale;
            }
            targetPos.Y = JabMath.LinearInterpolate(originPos.Y, targetPos.Y, posx);
        }
コード例 #3
0
ファイル: GameCamera.cs プロジェクト: meds/ChicksnVixens
        public void UpMoveCamPos()
        {
            float posx = PosX;

            float targetX = targetAreaPos.X;
            float originX = originPos.X;

            if (posx < originX)
            {
                posx = originX;
            }
            else if (posx > targetX)
            {
                posx = targetX;
            }

            float distBetween = Math.Abs(targetX - originX);

            targetX -= originX;
            posx    -= originX;

            posx /= targetX;


            PosY = targetPos.Y = JabMath.LinearInterpolate(originPos.Y, targetAreaPos.Y, posx);

            float lowestPoint = -512.0f;

            if (ScreenToWorld(Vector2.One).Y < lowestPoint)
            {
                PosY = targetPos.Y = PosY = PosY + (lowestPoint - ScreenToWorld(Vector2.One).Y);
            }
        }
コード例 #4
0
        static public float RandomFloatGravitate(float val)
        {
            float retval = RandomFloat;

            retval += JabMath.LinearInterpolate(0, val - retval, RandomFloat);
            return(retval);
        }
コード例 #5
0
        static public float RandomFloatInRangeGravitate(float min, float max, float gravitate)
        {
            float retval = (float)BaseGame.Random.NextDouble() * (max - min) + min;

            retval += JabMath.LinearInterpolate(0, gravitate - retval, RandomFloat);
            return(retval);
        }
コード例 #6
0
        public override void Update(GameTime dt)
        {
            base.Update(dt);

            if (lastPos != targetPos && !LevelSelect)
            {
                float totalLength = (lastPos - targetPos).Length();
                float curLength   = (Position - targetPos).Length();
                float prop        = 1.0f - curLength / totalLength;


                float interp = JabMath.Sin(curLength * JabMath.PI / totalLength);

                if (curLength == 0 && UniformWorldScale != minScale)
                {
                    if (lastcurLength != 0)
                    {
                        lastcurLength     = 0;
                        UniformWorldScale = minScale;
                    }
                    else
                    {
                        UniformWorldScale = JabMath.MoveTowards(UniformWorldScale, minScale, gttf(dt) * 5.0f, 0.001f);
                    }
                }
                else if (curLength != 0)
                {
                    lastcurLength = curLength;
                    if (totalLength < 300)
                    {
                        UniformWorldScale = JabMath.LinearInterpolate(minScale, 1.5f, interp);
                    }
                    else
                    {
                        UniformWorldScale = JabMath.LinearInterpolate(minScale, 0.8f, interp);
                    }
                }
            }
            else if (LevelSelect)
            {
                UniformWorldScale = JabMath.MoveTowards(UniformWorldScale, targetScale, gttf(dt) * 5.0f, 0.001f);
            }
            else
            {
                UniformWorldScale = JabMath.MoveTowards(UniformWorldScale, minScale, gttf(dt) * 5.0f, 0.001f);
            }
            Position = JabMath.MoveTowards(Position, targetPos, gttf(dt) * 5.0f, 5.0f);
        }
コード例 #7
0
ファイル: LevelButton.cs プロジェクト: meds/ChicksnVixens
        public override void Update(GameTime dt)
        {
            base.Update(dt);

            if (!(CheckFlag(Flags.FADE_IN) || CheckFlag(Flags.FADE_OUT)) && CheckStateFlag(StateFlag.FADE_IN_COMPLETE))
            {
                if (IsPressing)
                {
                    UniformScale = JabMath.LinearMoveTowards(UniformScale, 0.8f * ScaleFactor / Camera.Get.UniformWorldScale * 1.15f, gttf(dt) * 0.8f);
                }
                else
                {
                    float target = 0.8f * ScaleFactor / Camera.Get.UniformWorldScale;
                    UniformScale = JabMath.LinearMoveTowards(UniformScale, target, gttf(dt));
                }
            }
            else
            {
                UniformScale = 0.8f * ScaleFactor / Camera.Get.UniformWorldScale;
            }

            if (!(CheckFlag(Flags.FADE_IN) || CheckFlag(Flags.FADE_OUT)) && CheckStateFlag(StateFlag.FADE_IN_COMPLETE))
            {
                text.UniformScale = ScaleFactor / Camera.Get.UniformWorldScale * UniformScale * 1.2f;
            }
            else
            {
                text.UniformScale = ScaleFactor / Camera.Get.UniformWorldScale;
            }

            float alpha = JabMath.LinearInterpolate(1.0f, 0.0f, (Camera.Get.UniformWorldScale - 1) / 2.0f);

            if (lastAlpha != alpha)
            {
                if (alpha == 0)
                {
                    OnFadeOutComplete();
                }
                else if (alpha == 1)
                {
                    OnFadeInComplete();
                }
            }

            lastAlpha   = alpha;
            Colour      = new Color(alpha, alpha, alpha, alpha);
            text.Colour = Color.Red * alpha;
        }