using Otter;

namespace GiraffeRoller.entities
{
    class YGrass : Entity
    {
        private Spritemap<string> _spriteMap;

        public YGrass(float x, float y, Color color, float scale, int layer)
        {
            X = x; Y = y;
            _spriteMap = new Spritemap<string>(Assets.YGRASS, 25, 25);
            _spriteMap.Add("0", new int[] { 0 }, new float[] { 7f, 7f });
            _spriteMap.Add("1", new int[] { 1 }, new float[] { 7f, 7f });
            _spriteMap.Add("2", new int[] { 2 }, new float[] { 7f, 7f });
            _spriteMap.Add("3", new int[] { 3 }, new float[] { 7f, 7f });
            _spriteMap.Add("4", new int[] { 4 }, new float[] { 7f, 7f });
            _spriteMap.Add("5", new int[] { 5 }, new float[] { 7f, 7f });
            var rand = Rand.Int(0, 6);//one less than max should work
            //System.Console.WriteLine("rand: {0}", rand);

            if (rand == 0)
                _spriteMap.Play("0");
            else if (rand == 1)
                _spriteMap.Play("1");
            else if (rand == 2)
                _spriteMap.Play("2");
            else if (rand == 3)
                _spriteMap.Play("3");
            else if (rand == 4)
                _spriteMap.Play("4");
            else if (rand == 5)
                _spriteMap.Play("5");
            else
                _spriteMap.Play("0");
            if (color != Color.White)
                _spriteMap.Color = Color.Lerp(Color.White, Color.Orange, Rand.Float(.1f, .7f));
            else
                _spriteMap.Color = color;
            _spriteMap.Scale = scale;
            var va = Rand.Int(1, 2);
            if (va <= 1)
                _spriteMap.FlippedX = true;
            Graphic = _spriteMap;
            //System.Console.WriteLine("layer: {0}", layer);
            if (layer <= 0)
                Layer = -1;
            else
                Layer = 3;
        }

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