using LOoSE_sLOTS.UI;
using LOoSE_sLOTS.Utilities;
using Otter;
using System;

namespace LOoSE_sLOTS.entities
{
    class CharacterGettingPickedUp : Entity
    {
        private Spritemap<string> _spriteMap;

        public CharacterGettingPickedUp(float x, float y)
        {
            X = x; Y = y;
            X = x; Y = y;
            SetHitbox(20, 40, (int)Global.Type.SLOTMACHINEPERSON);
            Collider.X = -10;
            Collider.Y = -20;
            _spriteMap = new Spritemap<string>(Assets.SLOTMACHINEPERSON, 50, 50);
            _spriteMap.Add("dead", new int[] { 5 }, new float[] { 7f, 7f });
            _spriteMap.Add("on", new int[] { 0, 1 }, new float[] { 7f, 7f });
            _spriteMap.Add("dying", new int[] { 2, 3, 4 }, new float[] { 3f, 3f });
            _spriteMap.Play("on");
            _spriteMap.CenterOrigin();
            Layer = 2;
            Graphic = _spriteMap;
        }

        public override void Update()
        {
            base.Update();
            if (AmICollidingWithTruck(Collider) && Global.AllowedToCollideWithTruck)
            {
                X = Global.PickupTruckX - 30;
                Y = Global.PickupTruckY;
            }
        }//end update
        public bool AmICollidingWithTruck(Collider c)
        {
            var d = c.Collide(X, Y, (int)Global.Type.PICKUPTRUCK);
            if (d != null)
                return true;
            else
                return false;
        }

        public void Destroy()
        {
            RemoveSelf();
        }

        public override void Render()
        {
            base.Render();
        }
    }
}


