Ejemplo n.º 1
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.º 2
0
        public void Update(Map map)
        {
            Update(map, this);
            PlayerTakeDamage(5, this);
            DamageToNPC(map, this);

            Vector2Object hitPos = null;

            if (OutOfmap(this, out hitPos) == true)
            {
            }

            if (RemoveOnMapCollision(map.MapTree, this, out hitPos) == true)
            {
            }

            if (CollisionWithMovables(map, this, out hitPos) == true)
            {
            }


            if (_wet == true)
            {
                Game1.mapLive.MapProjectiles.Remove(this);
            }
            else
            {
                if (CompareF.LineVsMap(map.WaterTree, _track).Count > 0)
                {
                    _velocity /= 4;
                }
            }
        }
Ejemplo n.º 3
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.º 4
0
        public static bool StrikeLightning(Vector2 position, Inpc npc, short damage)
        {
            if (npc.Friendly == false)
            {
                if (LineSegmentF.Lenght(npc.Boundary.Origin, position) < 256)
                {
                    LineSegmentF _ray = new LineSegmentF(npc.Boundary.Origin, position);

                    if (CompareF.LineVsMap(Game1.mapLive.MapTree, new LineObject(Game1.mapLive, _ray)).Count == 0)
                    {
                        Game1.mapLive.mapLightings.Add(new Lightning(npc.Boundary.Origin, position, Game1.debug_thin, 6));
                        Game1.mapLive.mapLightings.Add(new Lightning(npc.Boundary.Origin, position, Game1.debug_thin, 2));
                        npc.Stun();
                        npc.Push(new Vector2(0, -0.2f));
                        npc.KineticDamage(damage);
                        Camera2DGame.Shake(5, position);

                        Sound _strikeSound = new Sound(Game1.soundElectro, position);
                        Game1.Sounds3D.Add(_strikeSound);
                        Game1.Sounds3D[Game1.Sounds3D.IndexOf(_strikeSound)].Play();
                    }
                    return(true);
                }
            }

            return(false);
        }
Ejemplo n.º 5
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.º 6
0
        public void Update()
        {
            if (CompareF.RectangleVsVector2(Boundary, MouseInput.MouseRealPosMenu()))
            {
                if (MouseInput.ScrolledDown())
                {
                    _offset -= 64f;
                }
                if (MouseInput.ScrolledUp())
                {
                    _offset += 64f;
                }
            }

            if (_offset < -((32 * _items.Count) - Boundary.Size.Y + 32))
            {
                _offset = -((32 * _items.Count) - Boundary.Size.Y + 32);
            }

            if (_offset > 0)
            {
                _offset = 0;
            }

            for (int i = 0; i < _items.Count; i++)
            {
                _items[i].Move(_offset);
                _items[i].Update(this);
            }
        }
Ejemplo n.º 7
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.º 8
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.º 9
0
        public void Update(List <Inpc> npcs)
        {
            foreach (Inpc npc in npcs)
            {
                if (npc != this)
                {
                    if (CompareF.RectangleFVsCircleF(BoundaryCircle, npc.Boundary) == true)
                    {
                        npc.KineticDamage(25);
                        LineSegmentF temp = new LineSegmentF(BoundaryCircle.Center, npc.Boundary.Origin);
                        npc.Push(temp.NormalizedWithZeroSolution() * 6f);
                        npc.Stun();
                        PlaySaw();
                    }
                }
            }

            if (CompareF.RectangleFVsCircleF(BoundaryCircle, Game1.PlayerInstance.Boundary) == true)
            {
                Game1.PlayerInstance.TakeDamage(25);
                LineSegmentF temp = new LineSegmentF(BoundaryCircle.Center, Game1.PlayerInstance.Boundary.Origin);
                Game1.PlayerInstance.Push(temp.NormalizedWithZeroSolution() * 6f);
                PlaySaw();
            }

            rotation += Game1.Delta;
        }
Ejemplo n.º 10
0
        public void UpdateBase()
        {
            _doubleClickTime.Update();

            if (CompareF.RectangleVsVector2(_listBoundary, MouseInput.MouseRealPosMenu()) == true)
            {
                if (MouseInput.MouseStateNew.LeftButton == ButtonState.Released && MouseInput.MouseStateOld.LeftButton == ButtonState.Pressed)
                {
                    if (CompareF.RectangleVsVector2(Boundary, MouseInput.MouseRealPosMenu()) == true && CompareF.RectangleVsVector2(_listBoundary, MouseInput.MouseRealPosMenu()) == true)
                    {
                        _doubleClickTime.Reset();

                        if (_doubleClickTime.Ready == false)
                        {
                            _clicks++;
                        }
                        else
                        {
                            _clicks = 1;
                            _doubleClickTime.Reset();
                        }

                        Selected = true;
                    }

                    if (CompareF.RectangleVsVector2(Boundary, MouseInput.MouseRealPosMenu()) == false)
                    {
                        Selected = false;
                    }
                }
            }
        }
Ejemplo n.º 11
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.º 12
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.º 13
0
        public void Update(ListPage page)
        {
            if (CompareF.RectangleVsVector2(Boundary, MouseInput.MouseRealPosMenu()) == true)
            {
                if (_state != ListItemStatesEnum.selected)
                {
                    _state = ListItemStatesEnum.hover;
                }
                if (MouseInput.MouseStateNew.LeftButton == ButtonState.Released && MouseInput.MouseStateOld.LeftButton == ButtonState.Pressed)
                {
                    page.CloseOthers(this);
                    _state = ListItemStatesEnum.selected;
                }
            }
            else
            {
                if (_state != ListItemStatesEnum.selected)
                {
                    _state = ListItemStatesEnum.none;
                }
            }

            if (_state == ListItemStatesEnum.selected)
            {
                foreach (Keys key in Enum.GetValues(typeof(Keys)))
                {
                    if (KeyboardInput.KeyboardStateNew.IsKeyDown(key))
                    {
                        Game1.STP.ControlKeys[_key] = key;
                        _state = ListItemStatesEnum.none;
                    }
                }
            }
        }
Ejemplo n.º 14
0
        public static void Explode(Vector2 pos, short damage)
        {
            CircleF circle = new CircleF(pos, 128);

            foreach (IParticle prtcl in Game1.mapLive.mapParticles)
            {
                if (prtcl.Boundary != null)
                {
                    LineSegmentF Temp = new LineSegmentF(pos, prtcl.Boundary.Origin);

                    Vector2?_thru = CompareF.IntersectionLineWithOthers(Temp, Game1.mapLive.TileMapLines, null);
                    if (_thru == null)
                    {
                        prtcl.Push(Vector2.Normalize(Temp.NormalizedWithZeroSolution() * (float)(Globals.GlobalRandom.NextDouble()) * 2));
                    }
                }
            }

            int j = 0;

            foreach (Inpc npc in Game1.mapLive.MapNpcs)
            {
                if (j < 8)
                {
                    LineSegmentF Temp = new LineSegmentF(pos, npc.Boundary.Origin);

                    Vector2?_thru = CompareF.IntersectionLineWithOthers(Temp, Game1.mapLive.TileMapLines, null);

                    if (_thru == null && LineSegmentF.Lenght(pos, npc.Boundary.Origin) < 256)
                    {
                        if (npc.Friendly == false)
                        {
                            npc.KineticDamage(damage);
                        }
                        npc.Push(Vector2.Normalize(Temp.NormalizedWithZeroSolution() * (float)(Globals.GlobalRandom.NextDouble()) * 2));
                        j++;
                    }
                }
            }

            int x = 4;

            for (int i = 0; i < x; i++)
            {
                Game1.mapLive.mapParticles.Add(new ParticleSmokeBig(circle.GenerateRandomPoint()));
            }
            for (int i = 0; i < x; i++)
            {
                Game1.mapLive.mapParticles.Add(new ParticleFireBig(circle.GenerateRandomPoint()));
            }
            for (int i = 0; i < x; i++)
            {
                Game1.mapLive.mapParticles.Add(new ParticleFireSmall(circle.GenerateRandomPoint()));
            }
            Camera2DGame.Shake(10, pos);

            Sound.PlaySoundPosition(pos, Game1.soundExplosion, CustomMath.RandomAroundZero(Globals.GlobalRandom) / 2f);
        }
Ejemplo n.º 15
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.º 16
0
 public void Update()
 {
     GunTimer.Update();
     if (_muzzleAlpha > 0)
     {
         _muzzleAlpha -= Game1.Delta / 50;
     }
     CompareF.DecreaseToZero(ref OffsetKick, 1f);
 }
Ejemplo n.º 17
0
        public void Draw()
        {
            float rotation = CompareF.VectorToAngle(LineSegment.ToVector2());
            int   distance = (int)Math.Ceiling(LineSegment.Lenght().Value);

            Effects.ColorEffect(new Vector4(1, 1, 1, _transparency));
            Game1.SpriteBatchGlobal.Draw(Game1.smoke, LineSegment.Start, null, new Rectangle(0, 0, distance, 16), new Vector2(0, 8), rotation, new Vector2(1f), Color.White, SpriteEffects.None);
            Effects.ResetEffect3D();
        }
Ejemplo n.º 18
0
        protected virtual void PlayerTakeDamage(ushort amount, IProjectile projectile)
        {
            List <Vector2Object> intersectionsPlayer = CompareF.LineIntersectionRectangle(Game1.PlayerInstance.Boundary, new LineObject(Game1.PlayerInstance, _track.Line));

            if (intersectionsPlayer?.Count > 0 && (_from is Inpc))
            {
                Game1.PlayerInstance.TakeDamage(amount);
                Game1.mapLive.MapProjectiles.Remove(projectile);
            }
        }
Ejemplo n.º 19
0
 protected void GetWet(Map map)
 {
     if (_wet == false)
     {
         if (CompareF.LineVsMap(map.WaterTree, _track).Count > 0)
         {
             _wet = true;
         }
     }
 }
Ejemplo n.º 20
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.º 21
0
        new public void DrawNormal()
        {
            Effects.RotateNormalsEffect(CompareF.VectorToAngle(_velocity), Vector2.One);
            Game1.SpriteBatchGlobal.Draw(Game1.Textures["rocketNormal"], _position, null, rotation: CompareF.VectorToAngle(_velocity), origin: new Vector2(20, 10));
            Effects.ResetEffect3D();

            if (_wet == false)
            {
                _trail.DrawNormal();
            }
        }
Ejemplo n.º 22
0
        public void LineAim(Vector2 realPos, object whoShoots, Vector2 origin, float barrelLenght, float reach)
        {
            RaySegment.Start = origin;
            RaySegment.End   = realPos;

            RayEnlonged = new LineSegmentF(RaySegment.Start, RaySegment.Start + RaySegment.NormalizedWithZeroSolution() * reach);

            RayBarrel.Start = origin;
            RayBarrel.End   = RaySegment.Start + RaySegment.NormalizedWithZeroSolution() * barrelLenght;

            RayDestination = CompareF.RaySegmentCalc(origin, RayEnlonged, whoShoots);
        }
Ejemplo n.º 23
0
 public override void Draw()
 {
     if (Selected == true)
     {
         Game1.SpriteBatchGlobal.Draw(Game1.Textures["TileBackSelected"], _boundary.Position, Color.White);
     }
     else if (CompareF.RectangleVsVector2(Boundary, MouseInput.MouseRealPosMenu()) == true && CompareF.RectangleVsVector2(_listBoundary, MouseInput.MouseRealPosMenu()) == true)
     {
         Game1.SpriteBatchGlobal.Draw(Game1.Textures["TileBackHover"], _boundary.Position, Color.White);
     }
     Game1.SpriteBatchGlobal.Draw(Game1.Textures[_tile.TextureName], _boundary.Position + new Vector2(4), sourceRectangle: new Rectangle(new Point(_tile.IndexInPicture.X * 32, _tile.IndexInPicture.Y * 32), new Point(32)), scale: new Vector2(1));
 }
Ejemplo n.º 24
0
        protected bool OutOfmap(IProjectile projectile, out Vector2Object hitPos)
        {
            hitPos = null;

            if (CompareF.LineIntersectionRectangle(Game1.mapLive.MapBoundary, _track).Count > 0)
            {
                hitPos = CompareF.NearestVector(_track.Line.Start, CompareF.LineIntersectionRectangle(Game1.mapLive.MapBoundary, _track));
                Game1.mapLive.MapProjectiles.Remove(projectile);
                return(true);
            }
            return(false);
        }
Ejemplo n.º 25
0
        protected bool RemoveOnMapCollision(MapTreeHolder map, IProjectile projectile, out Vector2Object hit)
        {
            hit = null;

            if (CompareF.LineVsMap(map, _track).Count > 0)
            {
                hit = CompareF.NearestVector(_track.Line.Start, CompareF.LineVsMap(map, _track));
                Game1.mapLive.MapProjectiles.Remove(projectile);
                return(true);
            }
            return(false);
        }
Ejemplo n.º 26
0
 public override void Draw()
 {
     if (Selected == true)
     {
         Game1.SpriteBatchGlobal.Draw(Game1.Textures["TileBackSelected"], _boundary.Position, sourceRectangle: new Rectangle(0, 0, 256 + 16, 256 + 16));
     }
     else if (CompareF.RectangleVsVector2(Boundary, MouseInput.MouseRealPosMenu()) == true && CompareF.RectangleVsVector2(_listBoundary, MouseInput.MouseRealPosMenu()) == true)
     {
         Game1.SpriteBatchGlobal.Draw(Game1.Textures["TileBackHover"], _boundary.Position, sourceRectangle: new Rectangle(0, 0, 256 + 16, 256 + 16));
     }
     Game1.SpriteBatchGlobal.Draw(_tex, _boundary.Position + new Vector2(8));
 }
Ejemplo n.º 27
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.º 28
0
        public bool Fire(LineSegmentF rayEnlonged, Vector2Object destination)
        {
            Vector2 barrel = rayEnlonged.Start + rayEnlonged.NormalizedWithZeroSolution() * GunBarrel;

            if (GunTimer.Ready == true)
            {
                Game1.sound.Play(1f, (float)(Globals.GlobalRandom.NextDouble() - 0.5f) / 2f, 0f);
                GunTimer.Reset();
                Game1.mapLive.MapProjectiles.Add(new ProjectileExplosive(Damage, CompareF.RotateVector2(rayEnlonged.NormalizedWithZeroSolution(), (float)(Globals.GlobalRandom.NextDouble() - 0.5f) / 8f) * VelocityOfProjectile, barrel, Owner));
                return(true);
            }
            return(false);
        }
Ejemplo n.º 29
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.º 30
0
        public void Update(List <Inpc> npcs)
        {
            if (Tint < 1f)
            {
                Tint += Game1.Delta / 100;
            }
            if (Tint > 1f)
            {
                Tint = 1f;
            }

            _timeShoot.Update();

            if (Health <= 0)
            {
                Kill();
            }

            if (LineSegmentF.Lenght(Boundary.Origin, Game1.PlayerInstance.Boundary.Origin) < 800)
            {
                //-----------
                _angle = Vector2.Dot(new LineSegmentF(Boundary.Origin, Game1.PlayerInstance.Boundary.Origin).NormalizedWithZeroSolution(), CompareF.AngleToVector(_rotation));

                _velocityOfRotation = 0f;
                if (_angle > 0.01f)
                {
                    _velocityOfRotation = -0.001f;
                }
                if (_angle < -0.01f)
                {
                    _velocityOfRotation = 0.001f;
                }

                //---------

                _rotation += _velocityOfRotation * Game1.Delta;

                _destination = CompareF.AngleToVector((float)(_rotation + Math.PI / 2f));
                _barrel      = Boundary.Origin + Vector2.Normalize(_destination) * (24 + 6);

                _destination = CompareF.RotateVector2(_destination, (float)(Globals.GlobalRandom.NextDouble() - 0.5f) / 4f);

                if (_timeShoot.Ready == true)
                {
                    _ammo--;
                    Game1.mapLive.MapProjectiles.Add(new Projectile(5, _destination, _barrel, this));
                    Sound.PlaySoundPosition(Boundary.Origin, Game1.sound);
                    _timeShoot.Reset();
                }
            }
        }