Exemplo n.º 1
0
        /// METODO: Chiama la Mossa(cellaselezionata) sulla cella && Controlla se il livello è completo && Salva best score
        public bool Move(Cella c)
        {
            /// muovo sulla cella selezionata
            this.livAttuale.Mossa(c);

            // aumenta il numero di mosse
            this.addMossa();

            aumentaMosseTotali();

            /// se il livello attuale è completo
            if (livAttuale.Completo())
            {
                /// trasforma il best score corrente in stringa
                livAttuale.Best_Score = mosse.ToString();

                /// Aggiungo alle settings bestscore+id
                if (appSettings.Contains("bestscore" + livAttuale.Id))
                {
                    /// Rimuovi vecchio best score
                    appSettings.Remove("bestscore" + livAttuale.Id);
                }
                /// Aggiungi nuovo best score
                appSettings.Add("bestscore" + livAttuale.Id, livAttuale.Best_Score);

                return true;

            }
            else return false;
        }
Exemplo n.º 2
0
        /// METODO: che cambia stato alla scacchiera a seconda della selezione
        public void Mossa(Cella c)
        {
            int id = c.Id;
            ///PRIMA COLONNA
            if (id%5 == 0)
            {
                /// ANGOLO ALTO SX
                if (id ==0)
                {
                    celle[1].changeState();
                    celle[5].changeState();

                }

                /// ANGOLO BASSO SX
                else if (id==20)
                {
                    celle[15].changeState();
                    celle[21].changeState();

                }

                /// BORDO SX
                else
                {
                    celle[id + 1].changeState();
                    celle[id - 5].changeState();
                    celle[id + 5].changeState();

                }
            }
            /// ULTIMA COLONNA
            else if (id % 5 == 4)
            {
                /// ANGOLO ALTO DX
                if (id==4)
                {
                    celle[3].changeState();
                    celle[9].changeState();

                }

                /// ANGOLO BASSO DX
                else if (id==24)
                {
                    celle[23].changeState();
                    celle[19].changeState();

                }
                /// BORDO DX
                else
                {
                    celle[id - 1].changeState();
                    celle[id - 5].changeState();
                    celle[id + 5].changeState();

                }
            }
            /// BORDO ALTO
            else if (id < 5)
            {
                celle[id - 1].changeState();
                celle[id + 1].changeState();
                celle[id + 5].changeState();

            }
            /// BORDO BASSO
            else if(id>19){
                celle[id - 1].changeState();
                celle[id + 1].changeState();
                celle[id - 5].changeState();

            }
            /// CASO GENERICO CENTRALE
            else {
                celle[id - 1].changeState();
                celle[id + 1].changeState();
                celle[id - 5].changeState();
                celle[id + 5].changeState();

            }
            /// Cambio stato cella selezionata
            celle[id].changeState();
        }