private bool IsPairWith(MovableAnimal other)
        {
            if (IsSeal || other.IsSeal)
            {
                return(false);
            }

            if (IsMultiColoredPenguin || other.IsMultiColoredPenguin)
            {
                return(true);
            }

            return(AnimalIndex == other.AnimalIndex);
        }
Ejemplo n.º 2
0
        public void PairFound(MovableAnimal penguin1, MovableAnimal penguin2)
        {
            int penguinType = MathHelper.Max(penguin1.AnimalIndex, penguin2.AnimalIndex);

            pairList.AddPair(penguinType);

            if (pairList.Completed)
            {
                PlayingState playingState = (PlayingState)ExtendedGame.GameStateManager.GetGameState(PenguinPairs.StateName_Playing);
                playingState.LevelCompleted(LevelIndex);
            }
            else
            {
                ExtendedGame.AssetManager.PlaySoundEffect("Sounds/snd_pair");
            }
        }
Ejemplo n.º 3
0
        public MovableAnimalSelector()
        {
            // define the four directions
            directions    = new Point[4];
            directions[0] = new Point(1, 0);
            directions[1] = new Point(0, -1);
            directions[2] = new Point(-1, 0);
            directions[3] = new Point(0, 1);

            // add the four arrows
            arrows = new Arrow[4];
            for (int i = 0; i < 4; i++)
            {
                arrows[i]          = new Arrow(i);
                arrows[i].Position = new Vector2(directions[i].X * arrows[i].Width, directions[i].Y * arrows[i].Height);
                AddChild(arrows[i]);
            }

            SelectedAnimal = null;
        }
Ejemplo n.º 4
0
        public override void HandleInput(InputHelper inputHelper)
        {
            if (selectedAnimal == null)
            {
                return;
            }
            base.HandleInput(inputHelper);

            for (int i = 0; i < 4; i++)
            {
                if (arrows[i].Pressed)
                {
                    SelectedAnimal.TryMoveInDirection(directions[i]);
                    return;
                }
            }
            if (inputHelper.MouseLeftButtonPressed())
            {
                SelectedAnimal = null;
            }
        }
Ejemplo n.º 5
0
        private void AddAnimal(int x, int y, char symbol)
        {
            Animal result = null;

            // TODO: check if symbol is an animal
            if (symbol == '@')
            {
                result = new Shark(this, new Point(x, y));
            }

            if (result == null)
            {
                int animalIndex = GetAnimalIndex(symbol);
                if (animalIndex < 0)
                {
                    animalIndex = GetAnimalInHoleIndex(symbol);
                }

                if (animalIndex >= 0)
                {
                    result = new MovableAnimal(animalIndex, this, new Point(x, y));
                }
            }
        }
Ejemplo n.º 6
0
 public override void Reset()
 {
     selectedAnimal = null;
 }
Ejemplo n.º 7
0
 public void SelectAnimal(MovableAnimal animal)
 {
     selector.SelectedAnimal = animal;
 }