Esempio n. 1
0
 public Enemy(GameScene game, Rectangle rectangle, Vector position, Vector velocity, int health)
     : base(game, rectangle, position, velocity, health)
 {
 }
Esempio n. 2
0
        public override void Tick(GameInput input)
        {
            if (health <= 0)
            {
                rectangle = RECTANGLE;
                stateCount = 256;
                DeathTick(input);
                base.Tick(input);
                return;
            }

            stateCount = (stateCount + 1) % 512;

            if (stateCount < 32)
            {
                rectangle = new Rectangle(new Vector(88, 256 - 4 * stateCount), new Vector(SIZE.X, 4 * stateCount));
                if (stateCount == 0)
                {
                    int nextPos = game.Random.Next(0, POSITION.Length - 1);
                    if (nextPos < currentPos)
                    {
                        position = POSITION[nextPos];
                        currentPos = nextPos;
                    }
                    else
                    {
                        position = POSITION[nextPos + 1];
                        currentPos = nextPos + 1;
                    }
                }
                animation = stateCount / 2;
            }
            else if (stateCount < 128)
            {
                if (stateCount == 32)
                {
                    rectangle = RECTANGLE;
                }
                animation = stateCount / 2 % 16;
            }
            else if (stateCount < 256)
            {
                if (stateCount % 32 == 0)
                {
                    game.PlaySound(GameSound.Mushroom);
                }
                if (health > INIT_HEALTH / 2)
                {
                    if (stateCount % 64 == 48)
                    {
                        SpreadSpores(8);
                    }
                }
                else
                {
                    if (stateCount % 32 == 24)
                    {
                        SpreadSpores(8);
                    }
                }
                animation = stateCount / 2 % 16;
            }
            else if (stateCount < 480)
            {
                animation = stateCount / 2 % 16;
            }
            else if (stateCount < 512)
            {
                rectangle = new Rectangle(new Vector(88, 128 + 4 * (stateCount - 480)), new Vector(SIZE.X, 128 - 4 * (stateCount - 480)));
                animation = 15 - (stateCount - 480) / 2;
            }

            base.Tick(input);
        }