コード例 #1
0
        public static void InitPickupEffects(AssetContext assets)
        {
            /*
             * int[] tcoords = { 0, 24, 48 };
             * int tx = AppRandom.Chooose<int>(tcoords);
             * int ty = AppRandom.Chooose<int>(tcoords, 2);
             */
            pickupTypes = new Dictionary <PickupType, cPickupInfo>()
            {
                [PickupType.HEALTH]      = new cPickupInfo(PickupType.HEALTH, new cSpriteRenderer("pickups", new MyIntRect(0, 0, 24, 24), assets), new Vector2f(16, 22), AddHealth),
                [PickupType.ARMOR]       = new cPickupInfo(PickupType.ARMOR, new cSpriteRenderer("pickups", new MyIntRect(0, 24, 24, 24), assets), new Vector2f(16, 22), AddArmor),
                [PickupType.AMMO]        = new cPickupInfo(PickupType.AMMO, new cSpriteRenderer("pickups", new MyIntRect(24, 0, 24, 24), assets), new Vector2f(16, 22), AddAmmo),
                [PickupType.COIN_GOLD]   = new cPickupInfo(PickupType.COIN_GOLD, new cAnimatedSpriteRenderer("coins-gold", new MyIntRect(0, 0, 16, 16), true), new Vector2f(16, 16), AddCoin),
                [PickupType.COIN_SILVER] = new cPickupInfo(PickupType.COIN_SILVER, new cAnimatedSpriteRenderer("coins-silver", new MyIntRect(0, 0, 16, 16), true), new Vector2f(16, 16), AddCoin),
                [PickupType.COIN_IRON]   = new cPickupInfo(PickupType.COIN_IRON, new cAnimatedSpriteRenderer("coins-copper", new MyIntRect(0, 0, 16, 16), true), new Vector2f(16, 16), AddCoin)
            };

            pickupProbabilityTable = new Tuple <int, PickupType>[4]
            {
                new Tuple <int, PickupType>(50, PickupType.HEALTH),
                new Tuple <int, PickupType>(5, PickupType.ARMOR),
                new Tuple <int, PickupType>(5, PickupType.AMMO),
                new Tuple <int, PickupType>(40, PickupType.COIN_GOLD)
            };

            roller = new ProbabilityRoll <PickupType>();
            roller.seed(pickupProbabilityTable);
        }
コード例 #2
0
        static PickupEffects()
        {
            /*
             * int[] tcoords = { 0, 24, 48 };
             * int tx = cAppRandom.Chooose<int>(tcoords);
             * int ty = cAppRandom.Chooose<int>(tcoords, 2);
             */
            pickupTypes = new Dictionary <PickupType, cPickupInfo>()
            {
                [PickupType.HEALTH] = new cPickupInfo(PickupType.HEALTH, AddHealth, new IntRect(0, 0, 24, 24)),
                [PickupType.ARMOR]  = new cPickupInfo(PickupType.ARMOR, AddArmor, new IntRect(0, 24, 24, 24)),
                [PickupType.AMMO]   = new cPickupInfo(PickupType.AMMO, AddAmmo, new IntRect(24, 0, 24, 24))
            };

            pickupProbabilityTable = new Tuple <int, PickupType>[3]
            {
                new Tuple <int, PickupType>(50, PickupType.HEALTH),
                new Tuple <int, PickupType>(25, PickupType.ARMOR),
                new Tuple <int, PickupType>(25, PickupType.AMMO)
            };

            roller = new ProbabilityRoll <PickupType>();
            roller.seed(pickupProbabilityTable);
        }
コード例 #3
0
        public override void Kill(cGameObject by)
        {
            this.Scene.LightMap.remove(this.p_followLight);
            this.Scene.LightMap.remove(this.eye);
            // this.spriteControl.ChangeState(new cSpriteState(MotionType.LIE, this.spriteControl.getCurrentState().HorizontalFacing));

            this.health = 0;
            this.killed = true;

            // int y = AppRandom.Choose<int>(new[] { 1,-1});

            this.Scene.QueueAction(() =>
            {
                Vector2f emitDirection = AppMath.Vec2NormalizeReturn(by.Velocity); //  new Vector2f(0.0f, y);

                float len   = (float)AppMath.Vec2Length(this.Velocity);
                float speed = len > 1.0f ? len : 0.0f;


                ShakeScreen.Init(this.pscene.Camera.ActualPosition);
                ShakeScreen.StartShake();


                Scene.Assets.PlaySound("blood_hit2", 25, this.position);
                //pscene.ParticleManager.Fireworks.NormalExplosion(new Particles.cEmissionInfo(this.Bounds.center, emitDirection));
                var e = pscene.ParticleManager["explosions"] as cExplosionController;
                e.NormalBlood(new EmissionInfo(this.Bounds.center, emitDirection, speed));

                e.Line(new EmissionInfo(this.Bounds.center, emitDirection));

                this.Scene.QueueAction(() =>
                {
                    /*
                     * if (this.IsOnGround)
                     * {
                     *  this.Scene.Effects.PlaceGround(this.Bounds.center.X, this.Bounds.rightBottom.Y, "side-explosion1");
                     * }
                     * else
                     */
                    {
                        this.Scene.Effects.Place(this.Bounds.center, "simple-explosion3");     // flash-black
                    }



                    // this.Scene.Effects.Place(intersection, "fire1");
                });

                // e.FastBlood(new EmissionInfo(this.Bounds.center,new Vector2f(0.0f, 0.0f)));

                //float gy = this.Bounds.rightBottom.Y; // ground y

                //pscene.Effects.PlaceGround(this.Bounds.center.X, gy, "side-explosion1");

                //pscene.EntityPool.getEntitiesInRadius()
                // pscene.Effects.Place(this.bounds.center, "simple-explosion2");
            }

                                   );

            this.Scene.QueueAction(() =>
            {
                Scene.Assets.PlaySound("coin_drop1", 20);

                ProbabilityRoll <int> numPickables = new ProbabilityRoll <int>();
                numPickables.add(70, 2);
                numPickables.add(30, 3);

                int num = numPickables.roll();
                for (int i = 0; i < num; ++i)
                {
                    pscene.EntityPool.AddPickup(
                        new cPickupAble(
                            this.Scene,
                            this.Bounds.center,
                            AppMath.GetRandomUnitVec(),                     // emitDirection,
                            PickupInfo.PickupType.COIN_GOLD)
                        );
                }
            });

            /*
             * new platformerGame.GameCommands.comPlacePickup(
             *  this.Scene,
             *  new GameObjects.cPickupAble(
             *      this.Scene,
             *      this.Scene.EntityPool.SpatialGrid,
             *      this.Bounds.center,
             *      emitDirection) )
             */
        }