Esempio n. 1
0
        //private void UpdateCookieFrogDistance()
        //{
        //    float dist =
        //        (StaticData.EngineManager.CookieRB.PositionXNACenter2D -
        //         StaticData.EngineManager.FrogRB.PositionXNACenter2D).Length();
        //    if (dist < CookieFrogMinDist)
        //    {
        //        CookieFrogMinDist = (int)dist;
        //    }
        //}

        private bool IsPathIntersected()
        {
            for (int i = 0; i < _placedCompSoFar.Count - 1; i++)
            {
                for (int j = 1; j < _placedCompSoFar.Count - 1; j++)
                {
                    Vector2 pInter = Vector2.Zero;
                    Vector2 p1     = _placedCompSoFar[i],
                            p2     = _placedCompSoFar[i + 1],
                            p3     = _placedCompSoFar[j],
                            p4     = _placedCompSoFar[j + 1];

                    if (_placedCompSoFar[i].X > 543 && _placedCompSoFar[i].X < 544)
                    {
                        int lk123 = 10;
                    }

                    if (_placedCompSoFar[j].X > 558 && _placedCompSoFar[j].X < 559)
                    {
                        int lk123 = 10;
                    }

                    if (MathHelperModule.IsIntersecting(p1, p2, p4, p3))
                    {
                        MathHelperModule.FindIntersection(p1, p2, p3, p4, out pInter);
                        if ((pInter != Vector2.Zero) &&
                            (pInter != p1) &&
                            (pInter != p2) &&
                            (pInter != p3) &&
                            (pInter != p4))
                        {
                            IsPathIntersection = true;
                            //if (IsReallyIntersection(pInter, new Vector2[] { p1, p2, p3, p4 }))
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }
Esempio n. 2
0
 private void TryRopeCut(Vector2 posPressed, Vector2 posReleased)
 {
     try
     {
         for (int i = 0; i < StaticData.EngineManager.SpringsManagerEngine.ListOfServices.Count; i++)
         {
             SpringService cService     = StaticData.EngineManager.SpringsManagerEngine.ListOfServices[i];
             Vector2       posRopeStart = new Vector2(cService.Masses[0].PositionXNA.X, cService.Masses[0].PositionXNA.Y);
             Vector2       posRopeEnd   = new Vector2(cService.Masses[cService.Masses.Count - 1].PositionXNA.X,
                                                      cService.Masses[cService.Masses.Count - 1].PositionXNA.Y);
             if (MathHelperModule.IsIntersecting(posPressed, posReleased, posRopeStart, posRopeEnd))
             {
                 if (!(cService is CatchableRopeService))
                 {
                     StaticData.EngineManager.SpringsManagerEngine.RemoveService(cService);
                     i--;
                 }
                 else
                 {
                     if ((cService as CatchableRopeService).IsActivated)
                     {
                         StaticData.EngineManager.SpringsManagerEngine.RemoveService(cService);
                         i--;
                     }
                 }
             }
             //if (!((posPressed.Y < posRopeStart.Y && posReleased.Y < posRopeStart.Y)
             //    || (posPressed.Y > posRopeEnd.Y && posReleased.Y > posRopeEnd.Y)))
             //{
             //    StaticData.EngineManager.SpringsManagerEngine.RemoveService(cService);
             //}
         }
     }
     catch (Exception)
     {
     }
 }