예제 #1
0
파일: Coin.cs 프로젝트: BlueBananasaurus/BP
        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);
            }
        }
예제 #2
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);
        }