public static void ReAddInverseCutPolygon(Vector2 posComp, BumperEntityPoly bumperEntity, ref List <List <IntPoint> > delPolys)
        {
            var bumpRigid     = bumperEntity.CompObj as BumpRigid;
            var bumpPosXNA    = bumpRigid.PositionXNA2D;
            var bumpPosCenter = bumpRigid.PositionXNACenter2D;

            Vector2 bP1, bP2;

            ProjectionHandler.FindBumperTwoBorderPoints(bumperEntity, out bP1, out bP2);
            Vector2 cP1 = posComp, cP2 = posComp;

            Vector2 interP;

            MathHelperModule.FindIntersection(bP1, bP2, cP1, cP2, out interP);

            Vector2 cutP = GetBumperCutStartingPoint(bumpRigid.Dir, bP1, bP2, posComp);

            if (!RigidsHelperModule.IsCloseEnough(interP,
                                                  (bumperEntity.CompObj as BumpRigid).PositionXNACenter2D,
                                                  20))
            // if the bump is not on the collision course with the rocket
            {
                // Rocket is not on a collision course with the bump, so cut down the del poly area vertically
                List <IntPoint> polyInverseCutVertical = GetInverseCutPolygon(cutP, posComp);
                delPolys = EntraSolver.GetPolySolution(delPolys, polyInverseCutVertical, ClipType.ctIntersection);
            }
        }
示例#2
0
 public override void ExcecuteAction()
 {
     try
     {
         if (Id == -1)
         {
             // Find nearest blower to the cookie and blow it up!
             BlowerService blowerService =
                 RigidsHelperModule.CatchNearestVisual2D(StaticData.EngineManager.CookieRB,
                                                         StaticData.EngineManager.BlowerManagerEngine
                                                         .ListOfServices.Select(
                                                             blower => (Visual2D)blower).ToList(),
                                                         1000) as BlowerService;
             if (blowerService != null)
             {
                 BlowerPressed = blowerService;
                 // blow it
                 blowerService.AddForceToCookie();
             }
         }
         else
         {
             BlowerService blowerService = StaticData.EngineManager.BlowerManagerEngine.GetService(this.Id);
             if (blowerService != null)
             {
                 BlowerPressed = blowerService;
                 blowerService.AddForceToCookie();
             }
         }
     }
     catch (Exception)
     {
     }
 }
        public static void ReAddBlowerBubbleRopeTrajectoryMissingAreas(Vector2 posComp,
                                                                       BumperEntityPoly bumperEntity,
                                                                       ref List <List <IntPoint> > delPolys)
        {
            var bumpRigid     = bumperEntity.CompObj as BumpRigid;
            var bumpPosXNA    = bumpRigid.PositionXNA2D;
            var bumpPosCenter = bumpRigid.PositionXNACenter2D;

            Vector2 bP1, bP2;

            ProjectionHandler.FindBumperTwoBorderPoints(bumperEntity, out bP1, out bP2);
            Vector2 cP1 = posComp, cP2 = posComp;

            Vector2 interP;

            MathHelperModule.FindIntersection(bP1, bP2, cP1, cP2, out interP);

            Vector2 cutP = GetBumperCutStartingPoint(bumpRigid.Dir, bP1, bP2, posComp);

            if (!RigidsHelperModule.IsCloseEnough(interP,
                                                  (bumperEntity.CompObj as BumpRigid).PositionXNACenter2D,
                                                  20))
            {
                List <IntPoint> polyInverseCutVertical = GetInverseCutPolygon(cutP, posComp);
                EntraDrawer.DrawIntoFile(new List <List <IntPoint> >()
                {
                    polyInverseCutVertical
                });
                EntraDrawer.DrawIntoFile(delPolys);

                delPolys = EntraSolver.GetPolySolution(delPolys, polyInverseCutVertical, ClipType.ctIntersection);
                EntraDrawer.DrawIntoFile(delPolys);
            }
        }
        public static List <List <BumperEntityPoly> > GroupizeCloseBumpers(List <BumperEntityPoly> rBumpers)
        {
            List <List <BumperEntityPoly> > result = new List <List <BumperEntityPoly> >();

            foreach (BumperEntityPoly bumper1 in rBumpers)
            {
                List <BumperEntityPoly> listOfCloseToBumper1 = new List <BumperEntityPoly>()
                {
                    bumper1
                };
                foreach (BumperEntityPoly bumper2 in rBumpers)
                {
                    if (bumper1 != bumper2)
                    {
                        BumpRigid b1 = bumper1.CompObj as BumpRigid;
                        BumpRigid b2 = bumper2.CompObj as BumpRigid;
                        if (RigidsHelperModule.IsCloseEnough(b1, b2, 90))
                        {
                            AddToProperList(bumper1, bumper2, ref listOfCloseToBumper1, ref result);
                            //listOfCloseToBumper1.Add(bumper2);
                        }
                    }
                }
                if (listOfCloseToBumper1.Count > 1)
                {
                    result.Add(listOfCloseToBumper1);
                }
            }

            for (int i = 0; i < result.Count; i++)
            {
                result[0].Sort(GroupSorter);
            }
            return(result);
        }
示例#5
0
 private void CheckRemoveCookie()
 {
     if (StaticData.GameSessionMode == SessionMode.PlayingMode)
     {
         if (RigidsHelperModule.GetDistance(this, StaticData.EngineManager.CookieRB)
             <= PlayabilitySimulatorEngineProlog.NarrativeDist)
         {
             //this.TextureType = TextureType.FrogWithCookie;
             StaticData.EngineManager.RigidsManagerEngine.ListOfSphereRigids.Remove(
                 StaticData.EngineManager.CookieRB);
             IsWon = true;
         }
     }
 }
示例#6
0
        public SphereRigid(SphereRigid anotherRB)
            : base(MathHelperModule.GetSphereRigid2DCoordinatesPositionXNA(anotherRB.PositionXNA, anotherRB.Radius),
                   MathHelperModule.GetPositionCenter(anotherRB.PositionXNA, anotherRB.Radius), TextureType.DefaultCircle)
        {
            this._positionCenter = anotherRB.PositionXNA;
            this._positionCenter = anotherRB.PositionCenterEngine;

            this.Width  = anotherRB.Width;
            this.Height = anotherRB.Height;

            this.vertices = RigidsHelperModule.MakeNewVPCMatrix(anotherRB.vertices);
            this.InverseInertiaTensorWorld = anotherRB.InverseInertiaTensorWorld;


            this.baseMomentOfInertia = anotherRB.baseMomentOfInertia;
            //this.basicEffect = anotherRB.basicEffect;
            this.acceleration          = anotherRB.acceleration;
            this.canSleep              = anotherRB.canSleep;
            this.Center                = anotherRB.Center;
            this.dAngle                = anotherRB.dAngle;
            this.torqueAccum           = anotherRB.torqueAccum;
            this.torque                = anotherRB.torque;
            this.EnlargingFactor       = anotherRB.EnlargingFactor;
            this.gravity               = anotherRB.gravity;
            this.Radius                = anotherRB.Radius;
            this.isAwake               = anotherRB.isAwake;
            this.IsCollidable          = anotherRB.IsCollidable;
            this.IsClicked             = anotherRB.IsClicked;
            this.LastFrameAcceleration = anotherRB.LastFrameAcceleration;
            this.LastFrameVelocity     = anotherRB.LastFrameVelocity;
            this.Mass            = anotherRB.Mass;
            this.InvMass         = anotherRB.InvMass;
            this.material        = anotherRB.material;
            this.motion          = anotherRB.motion;
            this.orientation     = anotherRB.orientation;
            this.RectangleArea   = anotherRB.RectangleArea;
            this.TextureType     = anotherRB.TextureType;
            this.sleepEpsilon    = anotherRB.sleepEpsilon;
            this.angVelocity     = anotherRB.angVelocity;
            this.angAcceleration = anotherRB.angAcceleration;
            this.divisions       = anotherRB.divisions;
            this.wired           = anotherRB.wired;
            this.InitRotation    = anotherRB.InitRotation;
            this.InitTorque      = anotherRB.InitTorque;
        }
        private void CatchCookieIfNear()
        {
            if (RigidsHelperModule.IsCloseEnough(StaticData.EngineManager.CookieRB, ring, Length))
            {
                List <RigidBody> lastMasses = new List <RigidBody>(this.Masses);
                this.Springs.Clear();

                this.Masses = DefaultAdder.GetMassesRope(this._nrOfMasses, lastMasses[0].PositionXNA3D,
                                                         StaticData.EngineManager.CookieRB.PositionXNACenter, _rigidSize, this._normalLength, this._rigidType, this._isCollide);
                this.Masses[0].TextureType  = TextureType.Pin;
                this.Masses[0].IsDrawable   = true;
                this.Masses[0].IsFixedRigid = true;
                BuildSprings(this.SpringConstant, this._normalLength, this.SpringFrictionConstant);

                lastMasses.ForEach(m => StaticData.EngineManager.RigidsManagerEngine.DeleteRigid(m));

                this.ApplyServiceOnRigid(StaticData.EngineManager.CookieRB);
                IsVisible   = true;
                IsActivated = true;
            }
        }
        public static void ReAddRocketTrajectoryMissingAreas(RocketEntityPoly rocketEntityPoly,
                                                             BumperEntityPoly bumperEntity,
                                                             ref List <List <IntPoint> > delPolys)
        {
            var bumpRigid     = bumperEntity.CompObj as BumpRigid;
            var bumpPosXNA    = bumpRigid.PositionXNA2D;
            var bumpPosCenter = bumpRigid.PositionXNACenter2D;

            Vector2 bP1, bP2;

            ProjectionHandler.FindBumperTwoBorderPoints(bumperEntity, out bP1, out bP2);
            Vector2 rP1, rP2;

            ProjectionHandler.FindRocketTwoBorderPoints(rocketEntityPoly, out rP1, out rP2);

            Vector2 interP;

            MathHelperModule.FindIntersection(bP1, bP2, rP1, rP2, out interP);

            Vector2 cutP = GetBumperCutStartingPoint(bumpRigid.Dir, bP1, bP2,
                                                     (rocketEntityPoly.CompObj as RocketCarrierService).PositionXNACenter2D);

            if (!RigidsHelperModule.IsCloseEnough(interP,
                                                  (bumperEntity.CompObj as BumpRigid).PositionXNACenter2D,
                                                  20))
            // if the bump is not on the collision course with the rocket
            {
                // Rocket is not on a collision course with the bump, so cut down the del poly area vertically
                List <IntPoint> polyInverseCutVertical = GetInverseCutPolygon(cutP, rocketEntityPoly);

                EntraDrawer.DrawIntoFile(new List <List <IntPoint> >()
                {
                    polyInverseCutVertical
                });

                delPolys = EntraSolver.GetPolySolution(delPolys, polyInverseCutVertical, ClipType.ctIntersection);
                EntraDrawer.DrawIntoFile(delPolys);
            }
        }
示例#9
0
        public override void Update(GameTime gameTime)
        {
            if (StaticData.GameSessionMode == SessionMode.PlayingMode)
            {
                if (!IsCookieCatched)
                {
                    if (RigidsHelperModule.IsCloseEnough(StaticData.EngineManager.CookieRB,
                                                         this, StaticData.BubbleCloseArea))
                    {
                        RigidInService = StaticData.EngineManager.CookieRB;
                        //SetAccIntoRigid(new Vector3(0, 5, 0));
                        //DisableRopesAcc();
                        IsCookieCatched = true;
                    }
                }
                else
                {
                    MoveServiceUpward();
                    RepositionMeAccordingToService();

                    if (
                        //(IsPinch && StaticData.GameSessionMode != SessionMode.DesignMode) ||
                        (IsClicked && StaticData.GameSessionMode != SessionMode.DesignMode))
                    {
                        //if (RigidInService != null)
                        //{
                        //    SetAccIntoRigid(new Vector3(0, -9.8f, 0));
                        //    EnableRopesAcc();
                        //}
                        RigidInService.SetAcceleration(new Vector3(0, -StaticData.GravityConstant, 0));
                        ShouldDie = true;
                    }
                }
            }
            base.Update(gameTime);
        }
示例#10
0
        public BoxRigid(BoxRigid anotherRB)
            : base(
                MathHelperModule.GetBoxRigid2DCoordinatesPositionXNA(anotherRB.PositionXNA, anotherRB.HalfSize.X, anotherRB.HalfSize.Y),
                MathHelperModule.GetPositionCenter(anotherRB.PositionXNA, anotherRB.HalfSize.X, anotherRB.HalfSize.Y), TextureType.DefaultBox)
        {
            //this.HalfSize = anotherRB.HalfSize;
            //this.PositionCenterEngine = MathHelperModule.GetPositionCenter(anotherRB.PositionXNA, anotherRB.HalfSize.X,
            //                                                         anotherRB.HalfSize.Y);
            //this.RectangleArea = MathHelperModule.GetBoxRigid2DCoordinatesPositionCenter(anotherRB.PositionCenterEngine,
            //                                                                             anotherRB.HalfSize.X,
            //                                                                             anotherRB.HalfSize.Y);
            //SetMaterial(anotherRB.material);
            //SetMass(HalfSize);

            //baseMomentOfInertia = Mass * Math.Max(HalfSize.X, HalfSize.Y) * Math.Max(HalfSize.X, HalfSize.Y) * 4 / 12f;
            //dAngle = 0;
            //vertices = new VertexPositionColor[5];
            //velocity = new Vector3(0, 0, 0);

            //InverseInertiaTensorWorld = new Matrix();
            //InverseInertiaTensorWorld.M11 = InverseInertiaTensorWorld.M22 = InverseInertiaTensorWorld.M33 = (float)1 / baseMomentOfInertia;
            //InverseInertiaTensorWorld.M44 = 1;

            //vertices[0].Position = this.PositionCenterEngine + new Vector3(HalfSize.X, HalfSize.Y, 0);
            //vertices[1].Position = this.PositionCenterEngine + new Vector3(-HalfSize.X, HalfSize.Y, 0);
            //vertices[2].Position = this.PositionCenterEngine + new Vector3(-HalfSize.X, -HalfSize.Y, 0);
            //vertices[3].Position = this.PositionCenterEngine + new Vector3(HalfSize.X, -HalfSize.Y, 0);
            //vertices[4].Position = this.PositionCenterEngine + new Vector3(HalfSize.X, HalfSize.Y, 0);

            this._positionCenter = anotherRB.PositionXNA;
            this._positionCenter = anotherRB.PositionCenterEngine;

            this.Width  = anotherRB.Width;
            this.Height = anotherRB.Height;

            this.vertices = RigidsHelperModule.MakeNewVPCMatrix(anotherRB.vertices);
            this.InverseInertiaTensorWorld = anotherRB.InverseInertiaTensorWorld;


            this.baseMomentOfInertia = anotherRB.baseMomentOfInertia;
            //this.basicEffect = anotherRB.basicEffect;
            this.acceleration          = anotherRB.acceleration;
            this.canSleep              = anotherRB.canSleep;
            this.Center                = anotherRB.Center;
            this.dAngle                = anotherRB.dAngle;
            this.torqueAccum           = anotherRB.torqueAccum;
            this.torque                = anotherRB.torque;
            this.EnlargingFactor       = anotherRB.EnlargingFactor;
            this.gravity               = anotherRB.gravity;
            this.HalfSize              = anotherRB.HalfSize;
            this.isAwake               = anotherRB.isAwake;
            this.IsCollidable          = anotherRB.IsCollidable;
            this.IsClicked             = anotherRB.IsClicked;
            this.LastFrameAcceleration = anotherRB.LastFrameAcceleration;
            this.LastFrameVelocity     = anotherRB.LastFrameVelocity;
            this.Mass            = anotherRB.Mass;
            this.InvMass         = anotherRB.InvMass;
            this.material        = anotherRB.material;
            this.motion          = anotherRB.motion;
            this.orientation     = anotherRB.orientation;
            this.RectangleArea   = anotherRB.RectangleArea;
            this.TextureType     = anotherRB.TextureType;
            this.sleepEpsilon    = anotherRB.sleepEpsilon;
            this.angVelocity     = anotherRB.angVelocity;
            this.angAcceleration = anotherRB.angVelocity;
            this.XAxis           = anotherRB.XAxis;
            this.YAxis           = anotherRB.YAxis;
        }
示例#11
0
        public override void Update(GameTime gameTime)
        {
            if (firstTime)
            {
                StaticData.EngineManager.CollisionManagerEngine.AddRigidWithNonCollidableRigids(this, StaticData.EngineManager.CookieRB);
                firstTime = false;
            }

            if (CanCatchCookie)
            {
                if (base.IsClicked && StaticData.GameSessionMode == SessionMode.DesignMode &&
                    StaticData.ManipulationGameMode == ManipulationGameMode.ChangingCompsDirection)
                {
                    // Change the direction
                    if ((int)this.Dir < 7)
                    {
                        UpdateDirection((Direction)((int)this.Dir + 1));
                    }
                    else
                    {
                        this.Dir = Direction.East;
                        UpdateDirection((Direction)((int)this.Dir));
                    }
                }
                if (StaticData.GameSessionMode == SessionMode.PlayingMode)
                {
                    if (!IsCookieCatched && !IsActivated)
                    {
                        // Is the cookie near?
                        if (RigidsHelperModule.IsCloseEnough(StaticData.EngineManager.CookieRB, this,
                                                             StaticData.RocketCarrierCloseArea))
                        {
                            if (!IsCookieAttachedToRope())
                            {
                                this.IsCookieCatched = true;
                                this.IsActivated     = true;
                                StaticData.EngineManager.RocketsCarrierManagerEngine.SetRocketNew(this);
                                this._particleEngine.MaxParticles = 4;
                            }
                        }
                    }
                    if (IsCookieCatched)
                    {
                        if (!CookieCollidedWithBump())
                        {
                            StaticData.EngineManager.CookieRB.PositionXNA = this.PositionXNACenter -
                                                                            StaticData.EngineManager.CookieRB.getHalfSize();
                        }
                        else
                        {
                            this.CanCatchCookie = false;
                        }
                        if (IsClicked)
                        {
                            this.CanCatchCookie = false;
                            var c = StaticData.EngineManager.CookieRB;
                            c.SetLastFrameAccelaration(Vector3.Zero);
                            c.SetInitTorque(0);
                            c.SetOrientation(0);
                            c.SetVelocity(Vector3.Zero);
                            c.AddForce(new Vector3(0, 3000, 0));
                            //Vector3 force = GetForceVector(this.Dir);
                            //StaticData.EngineManager.CookieRB.AddForce(new Vector3(force.X * 10, 0, 0));
                        }
                    }
                }
            }
            if (IsActivated && StaticData.GameSessionMode == SessionMode.PlayingMode)
            {
                this.AddForce(GetForceVector(this.Dir));
            }
            _particleEngine.EmitterLocation = new Vector2(this.PositionXNACenter.X, this.PositionXNA.Y + this.HalfSize.Y);
            _particleEngine.Update(VelocityVec);
            base.Update(gameTime);
        }
 public double GetCookieFrogDistance()
 {
     return(RigidsHelperModule.GetDistance(StaticData.EngineManager.CookieRB, StaticData.EngineManager.FrogRB));
 }