public override void knockBack(Vector2 direction, float magnitude, int damage, Entity attacker)
        {
            if (snakeState == SnakeWormState.KnockedBack)
            {
                return;
            }

            snakeState = SnakeWormState.KnockedBack;

            enemy_life -= damage;

            knockBackTime = 0;
            direction.Normalize();
            this.direction = (float)(Math.Atan2(direction.Y, direction.X));
            velocity       = direction * knockBackMagnitude;
        }
        public SnakeWorm(LevelState parentWorld, Vector2 position)
        {
            this.parentWorld = parentWorld;
            this.position    = position;
            this.dimensions  = new Vector2(24);

            snakeState = SnakeWormState.Moving;

            velocity = Vector2.Zero;

            direction      = (float)(Game1.rand.NextDouble() * Math.PI * 2);
            dirModifier    = 1.0f;
            switchTimer    = 0.0f;
            switchDuration = averageSwitchDuration;

            enemy_life = 16;
            enemy_type = EnemyType.Alien;

            prob_item_drop    = 0.3;
            number_drop_items = 4;

            tailData       = new TailPosition[tailPiecesCount, positionsCount];
            tailMostRecent = 0;
            for (int j = 0; j < tailPiecesCount; j++)
            {
                for (int i = 0; i < positionsCount; i++)
                {
                    tailData[j, i] = new TailPosition(position, direction);
                }
            }

            secondaryHitBoxes = new SecondaryHitBox[secondaryHitBoxCount];
            for (int i = 0; i < secondaryHitBoxCount; i++)
            {
                secondaryHitBoxes[i] = new SecondaryHitBox(position, new Vector2(16));
            }

            testAnim       = AnimationLib.getFrameAnimationSet("snakeA");
            tailAnimA      = AnimationLib.getFrameAnimationSet("snakeB");
            tailAnimB      = AnimationLib.getFrameAnimationSet("snakeC");
            animation_time = 0;
        }
        public override void update(GameTime currentTime)
        {
            animation_time += currentTime.ElapsedGameTime.Milliseconds;

            if (snakeState == SnakeWormState.Moving)
            {
                switchTimer += currentTime.ElapsedGameTime.Milliseconds;
                if (switchTimer > switchDuration)
                {
                    dirModifier *= -1;

                    switchTimer    = 0;
                    switchDuration = averageSwitchDuration + (float)(1000f * Game1.rand.NextDouble());
                }

                direction += turnAmount * dirModifier;

                velocity = new Vector2((float)(Math.Cos(direction) * wormSpeed), (float)(Math.Sin(direction) * wormSpeed));

                if (enemy_life < 1)
                {
                    snakeState = SnakeWormState.Dying;
                    parentWorld.pushCoin(this);
                }

                foreach (Entity en in parentWorld.EntityList)
                {
                    if (en.Enemy_Type == EnemyType.Alien)
                    {
                        continue;
                    }

                    if (Vector2.Distance(en.CenterPoint, CenterPoint) < 500f)
                    {
                        if (hitTest(en))
                        {
                            en.knockBack(en.Position - position, 2.0f, 5);
                        }
                    }
                }
            }
            else if (snakeState == SnakeWormState.KnockedBack)
            {
                knockBackTime += currentTime.ElapsedGameTime.Milliseconds;

                //direction += turnAmount * 3;

                if (knockBackTime > knockBackDuration)
                {
                    snakeState = SnakeWormState.Moving;
                }
            }
            else if (snakeState == SnakeWormState.Dying)
            {
                remove_from_list = true;
            }


            for (int i = 0; i < tailPiecesCount; i++)
            {
                if (i == tailPiecesCount - 1)
                {
                    tailData[i, tailMostRecent] = new TailPosition(position, direction + (float)(Math.PI));
                }
                else
                {
                    tailData[i, tailMostRecent] = tailData[(i - 1 + tailPiecesCount) % tailPiecesCount, (tailMostRecent + 1) % positionsCount];
                }
            }

            for (int i = 0; i < tailPiecesCount - 1; i++)
            {
                Vector2 posDiff = tailData[i + 1, tailMostRecent].position - tailData[i, tailMostRecent].position;

                tailData[i, tailMostRecent].rotation = (float)(Math.Atan2(posDiff.Y, posDiff.X));
            }

            tailMostRecent = (tailMostRecent + 1) % positionsCount;

            for (int i = 0; i < secondaryHitBoxCount; i++)
            {
                secondaryHitBoxes[i].Position = tailData[(int)(i * ((tailPiecesCount - 1.0f) / secondaryHitBoxCount)), tailMostRecent].position;
            }

            Vector2 newPos = position + (this.velocity * currentTime.ElapsedGameTime.Milliseconds);

            position = parentWorld.Map.reloactePosition(position, newPos, dimensions);
        }