Пример #1
0
        public override void OnCharacterCollision(CharacterEntity e, Direction d)
        {
            if (this.Delete)
            {
                return;
            }

            if (e.IsPlayer && e.HasUpwardVelocity)
            {
                if (this.Y + this.sprite.TextureRect.Height <= e.Y + Math.Abs(e.Velocity))
                {
                    new ResourceProxy().GetSound("coin").Play();
                    e.Y        = this.Y + this.sprite.TextureRect.Height;
                    e.Velocity = 5;
                    Velocity   = -20;
                    bumping    = true;

                    bumpCount--;

                    ((MainScene)_gameObject.SceneManager.CurrentScene).IncreaseScore(100);

                    if (bumpCount == 0)
                    {
                        Characters.EmptyCoinBox c = new Characters.EmptyCoinBox(this._gameObject);
                        c.X             = this.X;
                        c.Y             = this.Y;
                        c.OriginTileCol = this.OriginTileCol;
                        c.OriginTileRow = this.OriginTileRow;
                        ((MainScene)base._gameObject.SceneManager.CurrentScene).Entities.Add(c);

                        Tile t = new Tile();
                        t.Entity   = "emptycoinbox";
                        t.Frames   = 1;
                        t.ID       = 25;
                        t.Resource = "emptycoinbox1";
                        t.Static   = true;
                        ((MainScene)base._gameObject.SceneManager.CurrentScene).level.Tiles[c.OriginTileRow, c.OriginTileCol] = t;
                        this.Delete = true;
                    }
                    else
                    {
                        Characters.CoinBounce c = new Characters.CoinBounce(this._gameObject);
                        c.X             = this.X;
                        c.Y             = this.Y;
                        c.OriginTileCol = this.OriginTileCol;
                        c.OriginTileRow = this.OriginTileRow - 2;
                        c.IsStatic      = true;
                        //c.sprite.TextureRect = c.EntitySpriteSheet.GetNextSprite(Direction.RIGHT);
                        ((MainScene)base._gameObject.SceneManager.CurrentScene).Entities.Add(c);
                    }
                }
            }

            base.OnCharacterCollision(e, d);
        }
Пример #2
0
        public override void OnCharacterCollision(Entity e, Direction d)
        {
            if (this.Delete)
            {
                return;
            }

            if (e.IsPlayer && e.HasUpwardVelocity)
            {
                if (this.Y + this.sprite.TextureRect.Height <= e.Y + Math.Abs(e.Velocity))
                {
                    e.Y        = this.Y + this.sprite.TextureRect.Height;
                    e.Velocity = 5;
                    Velocity   = -20;
                    bumping    = true;
                    bumpCount--;
                    if (bumpCount == 0)
                    {
                        Entity c = new Characters.EmptyCoinBox(this.gameObject);
                        c.X             = this.X;
                        c.Y             = this.Y;
                        c.OriginTileCol = this.OriginTileCol;
                        c.OriginTileRow = this.OriginTileRow;
                        ((MainScene)base.gameObject.SceneManager.CurrentScene).Entities.Add(c);

                        Tile t = new Tile();
                        t.Entity   = "emptycoinbox";
                        t.Frames   = 1;
                        t.ID       = 12;
                        t.Resource = "emptycoinbox";
                        t.Static   = true;
                        ((MainScene)base.gameObject.SceneManager.CurrentScene).level.Tiles[c.OriginTileRow, c.OriginTileCol] = t;
                        this.Delete = true;
                    }
                    else
                    {
                        Characters.CoinBounce c = new Characters.CoinBounce(this.gameObject);
                        c.X             = this.X;
                        c.Y             = this.Y;
                        c.OriginTileCol = this.OriginTileCol;
                        c.OriginTileRow = this.OriginTileRow - 2;
                        c.IsStatic      = true;
                        ((MainScene)base.gameObject.SceneManager.CurrentScene).Entities.Add(c);
                    }
                }
            }

            base.OnCharacterCollision(e, d);
        }