Beispiel #1
0
        public void GenerateApple(bool[,] forbidden, Apple apple)
        {
            if (apple.IsSet)
            {
                return;
            }

            if (apple.IsSpecial)
            {
                GenerateSpecialAppleIfNecessary(forbidden, apple);
            }
            else
            {
                FindPositionAndSetApple(forbidden, apple);
            }
        }
Beispiel #2
0
 private void ThrowEventForSpecialApple(Apple apple)
 {
     if (apple.Speciality.Type.ToLower() == AppleSpeciality.SpeedingType)
     {
         OnChangedSpeed(new SnakeEventArgs(apple.Speciality.Value, apple.Speciality.Time));
     }
     else if (apple.Speciality.Type.ToLower() == AppleSpeciality.ShrinkingType)
     {
         OnShrinkingEvent(new SnakeEventArgs(apple.Speciality.Value, 0));
     }
     else if (apple.Speciality.Type.ToLower() == AppleSpeciality.InverseType)
     {
         OnInverseEvent(new SnakeEventArgs(0, apple.Speciality.Time));
     }
     else if (apple.Speciality.Type.ToLower() == AppleSpeciality.WinType)
     {
         OnHighScore(new EventArgs());
     }
 }
Beispiel #3
0
        public override void UnhideApple(Apple specialApple_DC)
        {
            SLApple specialApple = specialApple_DC as SLApple;

            specialApple.AppleImage.Visibility = Visibility.Visible;
        }
Beispiel #4
0
        public override void HideApple(Apple specialApple_DC)
        {
            SLApple specialApple = specialApple_DC as SLApple;

            specialApple.AppleImage.Visibility = Visibility.Collapsed;
        }
Beispiel #5
0
 public virtual void UnhideApple(Apple specialApple)
 {
     //Hook method to show apple in display
     ;
 }
Beispiel #6
0
 public virtual void HideApple(Apple specialApple)
 {
     //Hook method to hide apple in display
     ;
 }
Beispiel #7
0
        private void FindPositionAndSetApple(bool[,] forbidden, Apple apple)
        {
            Position freePosition = FindNextFreePosition(forbidden);

            SetApple(freePosition.X, freePosition.Y, apple);
        }
Beispiel #8
0
        protected override void ReadAppleTag(Level creationLevel_DC, XmlReader reader, Apple apple_DC)
        {
            SLLevel creationLevel = creationLevel_DC as SLLevel;
            SLApple apple         = apple_DC as SLApple;

            base.ReadAppleTag(creationLevel, reader, apple);

            reader.MoveToAttribute("img");
            string appleFilename = reader.Value;

            reader.MoveToAttribute("offsetY");
            apple.AppleOffsetY = Double.Parse(reader.Value);

            apple.AppleImage = SnakeUtils.LoadImage(appleFilename);
            creationLevel.LevelCanvas.Children.Add(apple.AppleImage);
        }