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); } }
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); }
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); } }
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); }
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); }