Ejemplo n.º 1
0
        public void Update()
        {
            _oldPosition      = _position;
            _offset           = Vector2.Normalize(_velocity) * 32;
            _position        += _velocity * Game1.Delta;
            _track.Line.Start = _oldPosition;
            _track.Line.End   = _position + _offset;

            List <Vector2Object> intersectionsPlayer = CompareF.LineIntersectionRectangle(Game1.PlayerInstance.Boundary, new LineObject(Game1.PlayerInstance, _track.Line));

            //if (intersectionsPlayer != null && intersectionsPlayer.Count > 0)
            //{
            //    Game1.mapLive.mapParticles.Remove(this);
            //}

            //foreach (Inpc npc in npcs)
            //{
            //    List<VectorObject> intersections = CompareF.LineIntersectionRectangle(npc, new LineObject(npc, _track.Line));

            //    if (intersections != null && intersections.Count > 0)
            //    {
            //        Game1.mapLive.mapParticles.Remove(this);
            //        break;
            //    }
            //    else if (CompareF.RectangleVsVector2(npc.Boundary, _track.Line.End) == true)
            //    {
            //        Game1.mapLive.mapParticles.Remove(this);
            //        break;
            //    }
            //}

            if (CompareF.LineVsMap(Game1.mapLive.MapTree, _track).Count > 0)
            {
                Game1.mapLive.mapParticles.Remove(this);
            }

            //foreach (IRectangleGet rec in elevators)
            //{
            //    List<VectorObject> intersections = CompareF.LineIntersectionRectangle(rec,new LineObject(rec, _track.Line));

            //    if (intersections !=null && intersections.Count>0)
            //    {
            //        Game1.mapLive.mapParticles.Remove(this);
            //    }
            //    else if(CompareF.RectangleVsVector2(rec, _track.Line.End) == true)
            //    {
            //        Game1.mapLive.mapParticles.Remove(this);
            //    }
            //}

            if (CompareF.LineIntersectionRectangle(Game1.mapLive.MapBoundary, _track).Count > 0)
            {
                Game1.mapLive.mapParticles.Remove(this);
            }

            if (CompareF.RectangleFVsRectangleF(Camera2DGame.Boundary, _track.Line.LineBoundingBox()) == false)
            {
                Game1.mapLive.mapParticles.Remove(this);
            }
        }
Ejemplo n.º 2
0
        public void Draw(RenderTarget2D target)
        {
            Game1.GraphicsGlobal.GraphicsDevice.SetRenderTarget(_contentTarget);
            Game1.GraphicsGlobal.GraphicsDevice.Clear(Color.Transparent);
            if (_type == ItemHolderTypes.basic)
            {
                Game1.SpriteBatchGlobal.Draw(Game1.Textures["PanelBackgroundLight"], position: Vector2.Zero, sourceRectangle: new Rectangle(new Point(0, 0), Boundary.Size.ToPoint()));
            }

            for (int i = 0; i < Items.Count; i++)
            {
                if (CompareF.RectangleFVsRectangleF(Boundary, Items[i].Boundary) == true)
                {
                    Items[i].Draw();
                }
            }

            Game1.GraphicsGlobal.GraphicsDevice.SetRenderTarget(target);
            Game1.SpriteBatchGlobal.Draw(_contentTarget, Boundary.Position, new Rectangle(0, 0, (int)Boundary.Size.X, (int)Boundary.Size.Y), Color.White);
            _scrollBar.Draw();

            if (_type == ItemHolderTypes.basic || _type == ItemHolderTypes.blue)
            {
                DrawRectangleBoundary.DrawBlue(Boundary.ToRectangle());
            }
            else if (_type == ItemHolderTypes.purple)
            {
                DrawRectangleBoundary.DrawPurple(Boundary.ToRectangle());
            }
        }
Ejemplo n.º 3
0
 public void Draw()
 {
     if (CompareF.RectangleFVsRectangleF(Camera2DGame.Boundary, _track.Line.LineBoundingBox()) == true)
     {
         Game1.SpriteBatchGlobal.Draw(Game1.rainDrop, _position, null, null, new Vector2(0, 1), CompareF.VectorToAngle(_velocity), null, Color.White, SpriteEffects.None);
     }
 }
Ejemplo n.º 4
0
        public void InsertRec(RectangleF rec)
        {
            if (CompareF.RectangleFVsRectangleF(Boundary, rec) == true)
            {
                if (LevelSize < QuadTreeSizes.Size_32)
                {
                    if (HasChilds == false)
                    {
                        HasChilds = true;
                        LeftTop   = new QuadTree(Boundary.Position.X,
                                                 Boundary.Position.Y, LevelSize + 1);
                        RightTop = new QuadTree(Boundary.Position.X
                                                + (LevelSizeInt / 2), Boundary.Position.Y,
                                                LevelSize + 1);
                        LeftBottom = new QuadTree(Boundary.Position.X,
                                                  Boundary.Position.Y + (LevelSizeInt / 2),
                                                  LevelSize + 1);
                        RightBottom = new QuadTree(Boundary.Position.X
                                                   + (LevelSizeInt / 2), Boundary.Position.Y
                                                   + (LevelSizeInt / 2),
                                                   LevelSize + 1);
                    }

                    LeftTop.InsertRec(rec);
                    RightTop.InsertRec(rec);
                    LeftBottom.InsertRec(rec);
                    RightBottom.InsertRec(rec);
                }
                else
                {
                    Holder = rec;
                }
            }
        }
Ejemplo n.º 5
0
        public void Pick()
        {
            if (CompareF.RectangleFVsRectangleF(Game1.PlayerInstance.Boundary, Boundary) == true)
            {
                if (_value == Pickups.tissue)
                {
                    Game1.PlayerInstance.AddTissue(10);
                }
                else if (_value == Pickups.electronics)
                {
                    Game1.PlayerInstance.AddElectronics(10);
                }
                else if (_value == Pickups.highTissue)
                {
                    Game1.PlayerInstance.AddTissue(50);
                }
                else if (_value == Pickups.highElectronics)
                {
                    Game1.PlayerInstance.AddElectronics(50);
                }

                Sound.PlaySound(Game1.soundCoin, CustomMath.RandomAroundZero(Globals.GlobalRandom) / 8f);
                Game1.mapLive.mapPickables.Remove(this);
            }
        }
Ejemplo n.º 6
0
        public void Update()
        {
            if (On == false)
            {
                foreach (Inpc npc in Game1.mapLive.MapNpcs.Reverse <Inpc>())
                {
                    if ((npc as Battery)?.Locked == false && CompareF.RectangleFVsRectangleF(Boundary, npc.Boundary) == true)
                    {
                        On = true;
                        Game1.mapLive.MapNpcs.Remove(npc);
                        Sound.PlaySoundPosition(Boundary.Origin, Game1.Sounds["BatteryInserted"]);

                        foreach (IRectanglePhysics recGet in Game1.mapLive.MapMovables)
                        {
                            if (recGet.Name == Target)
                            {
                                recGet.SetOn();
                            }
                        }

                        break;
                    }
                }
            }
            else
            {
                _transparency = 0.75f + (float)(Math.Sin(Game1.Time * 2 + Globals.GlobalRandom.NextDouble()) / 4);
            }
        }
Ejemplo n.º 7
0
 private void XCollideMoving(ref Vector2 velocity, RectangleF boundary, float bouncines, Vector2 friction, List <IRectanglePhysics> collection)
 {
     if (collection != null)
     {
         foreach (IRectanglePhysics rec in collection)
         {
             if (CompareF.RectangleFVsRectangleF(boundary, rec.Boundary) == true)
             {
                 if (boundary.Origin.X > rec.Boundary.Origin.X)
                 {
                     TouchRightMovable  = true;
                     velocity           = new Vector2(velocity.X * -bouncines + rec.velocity.X, velocity.Y);
                     boundary.Position  = new Vector2(rec.Boundary.CornerRightBottom.X, boundary.Position.Y);
                     VelocityReceived.X = rec.velocity.X;
                 }
                 else
                 {
                     TouchLeftMovable   = true;
                     velocity           = new Vector2(velocity.X * -bouncines + rec.velocity.X, velocity.Y);
                     boundary.Position  = new Vector2(rec.Boundary.CornerLeftTop.X - boundary.Size.X, boundary.Position.Y);
                     VelocityReceived.X = rec.velocity.X;
                 }
             }
         }
     }
 }
Ejemplo n.º 8
0
 override public void Pick()
 {
     if (CompareF.RectangleFVsRectangleF(Game1.PlayerInstance.Boundary, this._boundary))
     {
         Game1.PlayerInstance.PutOnVest();
         Game1.PlayerInstance.AccesWeapons();
         Game1.mapLive.mapPickables.Remove(this);
     }
 }
Ejemplo n.º 9
0
 override public void Pick()
 {
     if (Game1.PlayerInstance.Health < Game1.PlayerInstance.MaxHealth)
     {
         if (CompareF.RectangleFVsRectangleF(Game1.PlayerInstance.Boundary, this._boundary))
         {
             Game1.mapLive.mapPickables.Remove(this);
             Game1.PlayerInstance.Addhealth(25);
         }
     }
 }
Ejemplo n.º 10
0
        private void YCollideMoving(ref Vector2 velocity, RectangleF boundary, float bouncines, Vector2 friction, List <IRectanglePhysics> collection, bool walking)
        {
            if (collection != null)
            {
                foreach (IRectanglePhysics rec in collection)
                {
                    if (CompareF.RectangleFVsRectangleF(boundary, rec.Boundary) == true)
                    {
                        if (Math.Abs(maxVelocityClamped.X + rec.velocity.X) / boundary.IntersectionSize(rec.Boundary).X < Math.Abs(maxVelocityClamped.Y + rec.velocity.Y) / boundary.IntersectionSize(rec.Boundary).Y)
                        {
                            if (boundary.Origin.Y > rec.Boundary.Origin.Y && maxVelocityClamped.Y <= rec.velocity.Y)
                            {
                                TouchBottomMovable = true;
                                velocity           = new Vector2(velocity.X, velocity.Y * -bouncines + rec.velocity.Y);
                                boundary.Position  = new Vector2(boundary.Position.X, rec.Boundary.CornerRightBottom.Y);
                                velocity          -= new Vector2(0, friction.Y * velocity.Y);
                                VelocityReceived.Y = rec.velocity.Y;
                            }
                            else if (boundary.Origin.Y < rec.Boundary.Origin.Y && maxVelocityClamped.Y >= rec.velocity.Y)
                            {
                                TouchTopMovable = true;

                                if (Math.Abs(velocity.Y * -bouncines) > 0.2f)
                                {
                                    velocity = new Vector2(velocity.X, velocity.Y * -bouncines + rec.velocity.Y);
                                }
                                else
                                {
                                    velocity = new Vector2(velocity.X, rec.velocity.Y);
                                }

                                if (walking == false)
                                {
                                    velocity *= new Vector2(1 - friction.X, 1);
                                }

                                if (Math.Abs(rec.velocity.X) > Math.Abs(maxVelocityClamped.X))
                                {
                                    velocity           = new Vector2(rec.velocity.X, velocity.Y);
                                    VelocityReceived.X = rec.velocity.X;
                                }



                                boundary.Position  = new Vector2(boundary.Position.X, rec.Boundary.CornerRightTop.Y - boundary.Size.Y);
                                VelocityReceived.Y = rec.velocity.Y;
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 11
0
        public Vector2 IntersectionSize(RectangleF R)
        {
            if (CompareF.RectangleFVsRectangleF(this, R) == true)
            {
                float TempX = (Size.X + R.Size.X)
                              / 2 - Math.Abs(Origin.X - R.Origin.X);
                float TempY = (Size.Y + R.Size.Y)
                              / 2 - Math.Abs(Origin.Y - R.Origin.Y);

                return(new Vector2(TempX, TempY));
            }
            return(Vector2.Zero);
        }
Ejemplo n.º 12
0
        public void Update(Vector2 mousePos)
        {
            if (ControlsActive == true)
            {
                Controling();
            }

            CurretnObjectControl.PhysicsMove(this);

            if (MouseInput.MouseStateNew.LeftButton == ButtonState.Released)
            {
                (Weapons[2] as LaserGun).SetOff();
            }

            if (KeyboardInput.KeyboardStateOld.IsKeyUp(Keys.E) && KeyboardInput.KeyboardStateNew.IsKeyDown(Keys.E))
            {
                if (CurretnObjectControl is BuddyModule)
                {
                    foreach (ITriggers trgr in Game1.mapLive.mapTriggers)
                    {
                        if (CompareF.RectangleFVsRectangleF(Boundary, trgr.Boundary))
                        {
                            trgr.TriggerSwitch();
                        }
                    }

                    foreach (ICrate crt in Game1.mapLive.mapCrates.Reverse <ICrate>())
                    {
                        if (CompareF.RectangleFVsRectangleF(Boundary, crt.Boundary))
                        {
                            crt.Open();
                        }
                    }
                }
            }

            UpdateHealth();
            UpdateShield();

            CurretnObjectControl.HowILookCalc(this);

            if (Carry != null)
            {
                Carry.Carry(Boundary.Origin);
            }

            if ((CurretnObjectControl is BuddyModule) && (Resolver.VerticalPressure == true || Resolver.HorizontalPressure == true))
            {
                Kill();
            }
        }
Ejemplo n.º 13
0
        public List <RectangleF> FindIntersectRec(RectangleF rec)
        {
            List <RectangleF> rectangles = new List <RectangleF>();

            if (HasChilds == true)
            {
                if (CompareF.RectangleFVsRectangleF(LeftBottom.Boundary, rec) == true)
                {
                    rectangles.AddRange(LeftBottom.FindIntersectRec(rec));
                }

                if (CompareF.RectangleFVsRectangleF(LeftTop.Boundary, rec) == true)
                {
                    rectangles.AddRange(LeftTop.FindIntersectRec(rec));
                }

                if (CompareF.RectangleFVsRectangleF(RightBottom.Boundary, rec) == true)
                {
                    rectangles.AddRange(RightBottom.FindIntersectRec(rec));
                }

                if (CompareF.RectangleFVsRectangleF(RightTop.Boundary, rec) == true)
                {
                    rectangles.AddRange(RightTop.FindIntersectRec(rec));
                }

                return(rectangles);
            }
            else
            {
                if (LevelSize == QuadTreeSizes.Size_32 && Holder != null && CompareF.RectangleFVsRectangleF(rec, Boundary) == true)
                {
                    rectangles.Add(Holder);
                    return(rectangles);
                }

                return(rectangles);
            }
        }
Ejemplo n.º 14
0
        private void Walk()
        {
            if (StunLeft.Ready == true)
            {
                if ((_resolver.TouchTop == true || _resolver.TouchBottomMovable == true) || _resolver.InWater)
                {
                    if (Goes == ZombieStates.right)
                    {
                        Velocity = new Vector2(_maxSpeed.X, Velocity.Y);
                    }
                    if (Goes == ZombieStates.left)
                    {
                        Velocity = new Vector2(-_maxSpeed.X, Velocity.Y);
                    }
                }
            }

            StrikeTimer.Update();

            if (Game1.PlayerInstance.Alive == true)
            {
                if (StrikeTimer.Ready == true)
                {
                    if (CompareF.RectangleFVsRectangleF(Boundary, Game1.PlayerInstance.Boundary) == true)
                    {
                        if (StrikeTimer.Ready == true)
                        {
                            LineSegmentF line     = new LineSegmentF(Boundary.Origin, Game1.PlayerInstance.Boundary.Origin);
                            Vector2      velocity = line.NormalizedWithZeroSolution() * 4;
                            Game1.PlayerInstance.Push(new Vector2(velocity.X, velocity.Y / 2));
                            Game1.PlayerInstance.TakeDamage(10);

                            StrikeTimer.Reset();
                        }
                    }
                }
            }
        }
Ejemplo n.º 15
0
        public void Update(Vector2 mousePos)
        {
            if (ControlsActive == true)
            {
                Controling();
            }

            if (KeyboardInput.KeyboardStateOld.IsKeyUp(Keys.E) && KeyboardInput.KeyboardStateNew.IsKeyDown(Keys.E))
            {
                foreach (City city in Game1.mapLiveWorld.Cities)
                {
                    if (CompareF.RectangleFVsRectangleF(Boundary, city.Boundary))
                    {
                        city.GoInside();
                    }
                }
            }

            Time += Game1.Delta;

            if (ControlsActive == true)
            {
                Resolver.move(ref Velocity, new Vector2(2f), Boundary, 0f, new Vector2(0f), new Vector2(0.6f), new Vector2(0.1f), Game1.mapLiveWorld.MapMovables, 0, false, map: Game1.mapLiveWorld);
            }

            if (KeyboardInput.KeyboardStateOld.IsKeyUp(Keys.E) && KeyboardInput.KeyboardStateNew.IsKeyDown(Keys.E))
            {
                foreach (ITriggers trgr in Game1.mapLive.mapTriggers)
                {
                    if (CompareF.RectangleFVsRectangleF(Boundary, trgr.Boundary))
                    {
                        trgr.TriggerSwitch();
                    }
                }
            }
        }
Ejemplo n.º 16
0
        public void Controling()
        {
            CurretnObjectControl.ControlPlayer(this);

            if (KeyboardInput.KeyboardStateNew.IsKeyDown(Game1.STP.ControlKeys["Grab"]) &&
                KeyboardInput.KeyboardStateOld.IsKeyUp(Game1.STP.ControlKeys["Grab"]))
            {
                bool justLeft = false;

                if (Carry != null)
                {
                    Carry.LetGo(Velocity);
                    Carry = null;
                }
                else
                {
                    if (Game1.PlayerInstance.InVehicle == true)
                    {
                        LeftVehicle();
                        justLeft = true;
                    }

                    foreach (Inpc npc in Game1.mapLive.MapNpcs.Reverse <Inpc>())
                    {
                        if (justLeft == false)
                        {
                            if (npc is Icarry && Game1.PlayerInstance.InVehicle == false)
                            {
                                if (CompareF.RectangleFVsRectangleF
                                        (Game1.PlayerInstance.Boundary, npc.Boundary) == true)
                                {
                                    Carry = (npc as Icarry);
                                    break;
                                }
                            }
                        }

                        if (InVehicle == false && justLeft == false)
                        {
                            if (npc is Ivehicle)
                            {
                                if (Carry == null)
                                {
                                    if (CompareF.RectangleFVsRectangleF
                                            (Game1.PlayerInstance.Boundary, npc.Boundary) == true)
                                    {
                                        curretnBoundary = Boundary;

                                        Game1.mapLive.MapNpcs.Remove(npc);
                                        if (npc is PlayerMech)
                                        {
                                            CurretnObjectControl =
                                                new MechModule(this, npc.Boundary.Origin, (npc as Ivehicle).Health);
                                        }
                                        else if (npc is PlayerAircraft)
                                        {
                                            CurretnObjectControl =
                                                new AircraftModule(this, npc.Boundary.Origin, (npc as Ivehicle).Health);
                                        }
                                        InVehicle = true;
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }