using Otter;
using PpbbffttMiningHa.Utility;

namespace PpbbffttMiningHa.entities.MapEntities
{
    class TreasureThingy : Entity
    {
        private Spritemap<string> _spriteMap;
        private bool once;

        public TreasureThingy(float x, float y)
        {
            X = x; Y = y;
            _spriteMap = new Spritemap<string>(Assets.TREASURETHINGY, 40, 40);
            _spriteMap.Add("main", new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }, new float[] { 17f, 17f });
            _spriteMap.Play("main");
            SetHitbox(40, 40, Global.Type.DOOR);
            Collider.X = -2;
            Collider.Y = -2;
            _spriteMap.CenterOrigin();
            Graphic = _spriteMap;
            Layer = 0;
        }

        public override void Update()
        {
            base.Update();
            var colt = Collider.Collide((int)X, (int)Y, Global.Type.PLAYER);
            if (colt != null)
            {
                Global.HasTreasure = true;
                Global.Score += 10000;
                SoundManager.PlayRequestedSound("_loudKeyDrop", 2f);
                Global.WriteWord(170, 170, "FLY UP and OUT! GO!", Color.FromBytes(255, 255, 0, 255), 1, -10, Scene, 300, 12);

                Destroy();
            }
            if (!once)
            {
                once = true;
                Global.WriteWord(300, 400, "You're Rich", Color.FromBytes(255, 255, 0, 255), 1, -10, Scene, 300, 12);
            }
        }

        public override void Render()
        {
            base.Render();
            //Collider.Render(Color.Gold);
        }
        public void Destroy()
        {
            RemoveSelf();
        }
    }
}

