Ejemplo n.º 1
0
        /// <summary>
        /// metodo para acceder al level.
        /// </summary>
        /// <param name="level"> objeto level al que se accede. </param>
        public override void Visit(Level level)
        {
            if (level.ScreenList.Count >= 1)
            {
                this.LastScreen = level.ScreenList[level.ScreenList.Count - 1];
            }

            try
            {
                string name       = this.tag.AttributeList["Name"].Value;
                int    positionY  = Int32.Parse(this.tag.AttributeList["PositionY"].Value);
                int    positionX  = Int32.Parse(this.tag.AttributeList["PositionX"].Value);
                int    length     = Int32.Parse(this.tag.AttributeList["Length"].Value);
                int    width      = Int32.Parse(this.tag.AttributeList["Width"].Value);
                bool   check      = Convert.ToBoolean(this.tag.AttributeList["Check"].Value);
                string imagePath  = this.tag.AttributeList["ImagePath"].Value;
                string imagePath2 = this.tag.AttributeList["ImagePath2"].Value;

                IXML button = new ButtonCheck(name, positionY, positionX, length, width, this.LastScreen, imagePath, imagePath2, check);
                this.LastScreen.Add(button);
            }

            catch (Exception)
            {
                string message = "there was an error while fetching data from the XML file";
                throw new NotFoundOnXMLException(message);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// metodo que establece que la pantalla fue superada y se lo notifica al Observer.
        /// </summary>
        /// <param name="buttonCheck"> boton que fue clickeado. </param>
        /// <returns> retorna true si se paso de nivel. </returns>
        public bool NextLevel(ButtonCheck buttonCheck)
        {
            buttonCheck.Screen.LevelCompleted();
            Singleton <GeneralEngine> .Instance.Update();

            return(true);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// verifica que se haya superado el nivel.
        /// </summary>
        /// <param name="buttonCheck"> boton clickeado. </param>
        /// <returns> booleano. </returns>
        public bool Check(ButtonCheck buttonCheck)
        {
            this.clickNum += 1;

            OneAdapter.Adapter.Debug($"Button clicked!");
            buttonCheck.Select();
            this.AddButtonSelected(buttonCheck);

            this.AddCorrectButton(buttonCheck);

            if (this.clickNum == 2)
            {
                if (this.correctList.Count == 2)
                {
                    this.NextLevel(buttonCheck);
                    return(true);
                }
                else
                {
                    foreach (ButtonCheck button in this.selectedList)
                    {
                        button.Unselect();
                        OneAdapter.Adapter.SetImage(button.ButtonId, button.ImagePath);
                    }

                    this.correctList.Clear();
                    this.selectedList.Clear();
                    this.clickNum = 0;
                    return(false);
                }
            }

            return(false);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// agrega el boton a la lista correcta en el caso de que sea un boton correcto.
 /// </summary>
 /// <param name="buttonCheck"> boton que fue clickeado. </param>
 public void AddCorrectButton(ButtonCheck buttonCheck)
 {
     if (buttonCheck.Check & !this.correctList.Contains(buttonCheck))
     {
         this.correctList.Add(buttonCheck);
     }
 }
Ejemplo n.º 5
0
 /// <summary>
 /// metodo que dibuja un ButtonCheck en Unity.
 /// </summary>
 /// <param name="buttonCheck"> ButtonCheck a dibujar. </param>
 public void RenderButtonCheck(ButtonCheck buttonCheck)
 {
     buttonCheck.ButtonId = this.adapter.CreateButton((int)buttonCheck.PositionX, (int)buttonCheck.PositionY, (int)buttonCheck.Width, (int)buttonCheck.Length, "#FFFFFFFF", buttonCheck.Action);
     this.adapter.SetImage(buttonCheck.ButtonId, buttonCheck.ImagePath);
     this.adapter.SetText(buttonCheck.ButtonId, string.Empty);
 }
Ejemplo n.º 6
0
 /// <summary>
 /// añade el boton a la lista de botones seleccionados.
 /// </summary>
 /// <param name="buttonCheck">boton seleccionado.</param>
 public void AddButtonSelected(ButtonCheck buttonCheck)
 {
     this.selectedList.Add(buttonCheck);
     OneAdapter.Adapter.SetImage(buttonCheck.ButtonId, buttonCheck.ImagePath2);
 }