Example #1
0
        public override void Hit(int amount, cGameObject entity_by)
        {
            base.Hit(amount, entity_by);

            if (this.health <= 0)
            {
                this.Kill(entity_by);
                //this.Scene.ParticleManager.AddNormalBloodExplosion(this.Bounds.center);


                return;
            }

            //this.spriteControl.ChangeState(new cSpriteState(MotionType.FALL, this.spriteControl.getCurrentState().HorizontalFacing));
            //this.Scene.ParticleManager.AddLittleBloodExplosion(this.Bounds.center, 3);

            this.Scene.QueueAction(
                () =>
            {
                Scene.Assets.PlaySound("body_hit1", 8);
                var e = pscene.ParticleManager["explosions"] as cExplosionController;
                // e.LittleBlood(new Particles.EmissionInfo(this.Bounds.center));
                var dir = AppMath.Vec2NormalizeReturn(entity_by.Velocity);

                float maxLen = (float)AppMath.GetRandomDoubleInRange(10.0, this.Bounds.diagonalLength());
                Vector2f end = AppMath.ScaleVector(entity_by.Position, AppMath.Vec2NormalizeReturn(dir), maxLen);

                // approximately:
                Vector2f point = AppMath.GetRandomPointOnLine(entity_by.Position, end);
                e.LittleLine(new Particles.EmissionInfo(point, dir));
            });
        }
Example #2
0
        public static cGameObject fromParticle(Particle p)
        {
            cGameObject go = new cGameObject();

            go.Position         = p.Pos;
            go.LastPosition     = p.LastPos;
            go.Velocity         = p.Vel;
            go.viewPosition     = p.ViewPos;
            go.HitCollisionRect = new cAABB();
            go.HitCollisionRect.SetDims(new Vector2f(1, 1));
            go.HitCollisionRect.SetPosByCenter(p.Pos);
            return(go);
        }
        public static cGameObject MakeWall(AABB box)
        {
            cGameObject go = new cGameObject();

            go.Position     = box.center;
            go.LastPosition = go.Position;
            go.Velocity     = new Vector2f(0.0f, 0.0f);
            go.ViewPosition = go.Position;
            //box.SetDims(new Vector2f(Constants.TILE_SIZE, Constants.TILE_SIZE));
            go.Bounds           = box;
            go.HitCollisionRect = box;
            go.MovAble          = false; // important!
            go.Mass             = 0.0f;
            return(go);
        }
        public static cGameObject fromParticle(Particle p)
        {
            cGameObject go = new cGameObject();

            go.Position     = p.Pos;
            go.LastPosition = p.LastPos;
            go.Velocity     = p.Vel;
            go.viewPosition = p.ViewPos;
            go.Bounds.SetDims(new Vector2f(2.0f, 2.0f));
            go.Bounds.SetPosByCenter(p.Pos);
            go.mass             = 1.0f;
            go.movAble          = true;
            go.HitCollisionRect = go.Bounds.ShallowCopy();
            return(go);
        }
Example #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="scene"></param>
        /// <param name="pos">position</param>
        /// <param name="owner">owner gameobject ex. cCharacter</param>
        /// <param name="direction">normalized vector of direction</param>
        public cBullet(cGameObject owner, Vector2f pos, Vector2f direction) : base(owner.Scene, pos)
        {
            this.alive   = true;
            this.alpha   = 255.0f;
            this.owner   = owner;
            this.heading = direction;
            this.bounds  = new cAABB();
            this.bounds.SetDims(new Vector2f(1.0f, 1.0f));
            this.oppositeDir  = new Vector2f(-this.heading.X * SLUG_LENGTH, -this.heading.Y * SLUG_LENGTH);
            this.intersection = new Vector2f(0.0f, 0.0f);
            this.bounds.SetPosByTopLeft(pos);
            this.velocity.X = this.heading.X * Constants.BULLET_START_SPEED;
            this.velocity.Y = this.heading.Y * Constants.BULLET_START_SPEED;
            orientation     = cAppMath.GetAngleOfVector(heading);

            this.sprite          = new Sprite(cAssetManager.GetTexture(Constants.BULLET_TEXTURE_NAME)); // bullet_yellow_sm; bullet_light_gree
            this.sprite.Scale    = new Vector2f(0.5f, 0.5f);
            this.sprite.Rotation = (float)cAppMath.RadianToDegress(this.orientation);
            this.sprite.Origin   = new Vector2f(this.sprite.TextureRect.Width - TEXTURE_INTERSECTION_OFFSET, this.sprite.TextureRect.Height / 2.0f);
        }
Example #6
0
        public override void Hit(int amount, cGameObject entity_by)
        {
            base.Hit(amount, entity_by);

            if (this.health <= 0)
            {
                this.Kill(entity_by);
                //this.Scene.ParticleManager.AddNormalBloodExplosion(this.Bounds.center);


                return;
            }

            //this.spriteControl.ChangeState(new cSpriteState(MotionType.FALL, this.spriteControl.getCurrentState().HorizontalFacing));
            //this.Scene.ParticleManager.AddLittleBloodExplosion(this.Bounds.center, 3);

            this.Scene.QueueCommand(
                () => {
                pscene.ParticleManager.Explosions.LittleBlood(new Particles.cEmissionInfo(this.Bounds.center));
            });
        }
Example #7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="scene"></param>
        /// <param name="pos">position</param>
        /// <param name="owner">owner gameobject ex. cCharacter</param>
        /// <param name="direction">normalized vector of direction</param>
        public cBullet(cGameObject owner, BulletBreed breed, Vector2f pos, Vector2f direction) : base(owner.Scene, pos)
        {
            this.owner = owner;
            this.breed = breed;

            this.alive = true;
            this.alpha = 255.0f;
            // proci határozza meg, hogy milyen alaplap foglalat és milyen RAM!!
            this.heading = direction;
            this.Bounds  = new AABB();
            this.Bounds.SetDims(new Vector2f(1.0f, 1.0f));
            this.oppositeDir  = new Vector2f(-this.heading.X * breed.slugLength, -this.heading.Y * breed.slugLength);
            this.intersection = new Vector2f(0.0f, 0.0f);
            this.Bounds.SetPosByTopLeft(pos);
            this.velocity.X = this.heading.X * breed.startSpeed;
            this.velocity.Y = this.heading.Y * breed.startSpeed;
            orientation     = AppMath.GetAngleOfVector(heading);

            this.sprite          = new Sprite(this.breed.sprite); // bullet_yellow_sm; bullet_light_gree
            this.sprite.Rotation = (float)AppMath.RadianToDegress(this.orientation);
        }
Example #8
0
        public void Kill(cGameObject by)
        {
            this.Scene.LightMap.remove(this.p_followLight);
            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;

            Vector2f emitDirection = cAppMath.Vec2NormalizeReturn(by.Velocity);

            this.Scene.QueueCommand(
                () => { pscene.ParticleManager.Explosions.NormalBlood(new Particles.cEmissionInfo(this.Bounds.center, emitDirection)); }
                //new GameCommands.comNormalBloodExplosion(this.Scene, new Particles.cEmissionInfo(this.Bounds.center, emitDirection))
                );

            this.Scene.QueueCommand(
                () => {
                pscene.EntityPool.AddPickup(
                    new cPickupAble(
                        this.Scene,
                        this.Scene.EntityPool.SpatialGrid,
                        this.Bounds.center,
                        emitDirection
                        )
                    );
            }

                /*
                 * new platformerGame.GameCommands.comPlacePickup(
                 *  this.Scene,
                 *  new GameObjects.cPickupAble(
                 *      this.Scene,
                 *      this.Scene.EntityPool.SpatialGrid,
                 *      this.Bounds.center,
                 *      emitDirection) )
                 */
                );
        }
Example #9
0
        protected void checkCollisionWithWorld(float step_time)
        {
            cWorld world = Scene.World;

            if (false == pulling)
            {
                // check collisions with world
                List <cAABB> wallsPossibleColliding = world.getCollidableBlocks(Bounds);

                // we must check this, because we need to iterate through the possible
                // colliding tiles from other direction according to this condition
                if (velocity.X > 0.0f)
                {
                    for (int i = 0; i < wallsPossibleColliding.Count; i++)
                    {
                        cGameObject wallObject = cGameObject.MakeWall(wallsPossibleColliding[i]);
                        if (cSatCollision.checkAndResolve(this, wallObject, step_time, true))
                        {
                            break;
                        }
                    }
                }
                else
                {
                    // we have to iterate from "end" to the "start" in order to have the last colliding block below us
                    for (int i = wallsPossibleColliding.Count - 1; i >= 0; i--)
                    {
                        cGameObject wallObject = cGameObject.MakeWall(wallsPossibleColliding[i]);
                        if (cSatCollision.checkAndResolve(this, wallObject, step_time, true))
                        {
                            break;
                        }
                    }
                }
            }
        }
Example #10
0
 public virtual void MeleeHit(int amount, cGameObject entity_by)
 {
     this.Hit(amount, entity_by);
     // Vector2f towardsMe = AppMath.Vec2NormalizeReturn(this.HitCollisionRect.center - entity_by.HitCollisionRect.center);
     // this.force = towardsMe * 50000;
 }
Example #11
0
 public virtual void Hit(int amount, cGameObject entity_by)
 {
     this.health -= amount;
 }
Example #12
0
 public virtual void Kill(cGameObject by)
 {
 }
Example #13
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) )
             */
        }
Example #14
0
 public override void Kill(cGameObject by)
 {
     Scene.LightMap.remove(this.light);
 }