Esempio n. 1
0
 private void Start()
 {
     map   = GameObject.Find("Map").GetComponent <Map>();
     state = Statee.Editor;
     GameObject.Find("EditorCanvas").GetComponent <Canvas>().enabled = true;
     GameObject.Find("GameCanvas").GetComponent <Canvas>().enabled   = false;
 }
Esempio n. 2
0
 private void Delete()
 {
     Block2.Text  = null;
     Block1.Text  = null;
     BlockDo.Text = null;
     State        = Statee.first;
 }
Esempio n. 3
0
 public void StopGame()
 {
     GameObject.Find("Score").GetComponent <Score>().ResetScore();
     map.LoadEditorState();
     GameObject.Find("EditorCanvas").GetComponent <Canvas>().enabled = true;
     GameObject.Find("GameCanvas").GetComponent <Canvas>().enabled   = false;
     state = Statee.Editor;
 }
Esempio n. 4
0
 public void StartGame()
 {
     GameObject.Find("Score").GetComponent <Score>().ResetScore();
     GameObject.Find("EditorCanvas").GetComponent <EditorController>().DisableAllButtons();
     map.SaveEditorState();
     GameObject.Find("EditorCanvas").GetComponent <Canvas>().enabled = false;
     GameObject.Find("GameCanvas").GetComponent <Canvas>().enabled   = true;
     state     = Statee.Game;
     coroutine = StartCoroutine(NextIteration());
 }
Esempio n. 5
0
 private void ButtonDevine(object sender, RoutedEventArgs e)
 {
     if (!CantDo() || (!(BlockMain.Text.ToLower().IndexOf('e') == -1)))
     {
         if (State == Statee.result)
         {
             Delete();
         }
         if (State == Statee.first)
         {
             if ((BlockMain.Text == "-") || (BlockMain.Text == ""))
             {
                 BlockMain.Text = "0";
             }
             if (System.Convert.ToDouble(BlockMain.Text) == 0)
             {
                 NumberString = Invalid;
                 State        = Statee.result;
             }
             else
             {
                 NumberString = System.Convert.ToString(1 / (System.Convert.ToDouble(BlockMain.Text)));
             }
             BlockMain.Text = NumberString;
         }
         if (State == Statee.second)
         {
             if ((Block2.Text == "-") || (Block2.Text == ""))
             {
                 Block2.Text = "0";
             }
             if (System.Convert.ToDouble(Block2.Text) == 0)
             {
                 NumberString   = Invalid;
                 BlockMain.Text = NumberString;
                 Block2.Text    = "0";
                 State          = Statee.result;
             }
             else
             {
                 NumberString = System.Convert.ToString(1 / (System.Convert.ToDouble(Block2.Text)));
                 Block2.Text  = NumberString;
             }
         }
     }
 }
Esempio n. 6
0
        private void ButtonEquals(object sender, RoutedEventArgs e)
        {
            if (State != Statee.result)
            {
                if (Block1.Text != "")
                {
                    if (Block2.Text != "")
                    {
                        double Num1 = System.Convert.ToDouble(Block1.Text);
                        double Num2 = System.Convert.ToDouble(Block2.Text);
                        if ((Num2 == 0) && (BlockDo.Text == "÷"))
                        {
                            BlockMain.Text = Invalid;
                            Block2.Text    = "0";
                        }
                        else
                        {
                            Counter(Num1, Num2);
                            BlockMain.Text = NumResult.ToString();
                        }

                        State = Statee.result;
                    }
                    else
                    {
                        double Num1 = NumResult;
                        double Num2 = System.Convert.ToDouble(Block1.Text);
                        if ((Num2 == 0) && (BlockDo.Text == "÷"))
                        {
                            BlockMain.Text = Invalid;
                            Block2.Text    = "0";
                        }
                        else
                        {
                            Counter(Num1, Num2);
                            Block2.Text    = null;
                            BlockMain.Text = System.Convert.ToString(NumResult);
                        }
                    }
                }
                else
                {
                    if ((BlockMain.Text == "-") || (BlockMain.Text == "") || (String.IsNullOrEmpty(BlockMain.Text)))
                    {
                        NumberString = "0";
                    }
                    else
                    {
                        NumberString = System.Convert.ToString(System.Convert.ToDouble(BlockMain.Text));
                    }
                    BlockMain.Text = NumberString;
                }
            }
            else
            if ((!CantDo() || (!(BlockMain.Text.ToLower().IndexOf('e') == -1))) && (Block1.Text != ""))
            {
                double Num1 = NumResult;
                double Num2 = System.Convert.ToDouble(Block1.Text);

                if (Block2.Text != "")
                {
                    Num2 = System.Convert.ToDouble(Block2.Text);
                }

                if ((Num2 == 0) && (BlockDo.Text == "÷"))
                {
                    BlockMain.Text = Invalid;
                    Block2.Text    = "0";
                    State          = Statee.result;
                }
                else
                {
                    Counter(Num1, Num2);
                    BlockMain.Text = System.Convert.ToString(NumResult);
                }
            }
        }
Esempio n. 7
0
        private void ButtonDo(object sender, RoutedEventArgs e)
        {
            if ((State == Statee.first) && ((BlockMain.Text == "") || (BlockMain.Text == "0")) && (sender as Button).Content.ToString() == "-")
            {
                NumberString   = "-";
                BlockMain.Text = NumberString;
            }
            else
            if (CantDo() && (sender as Button).Content.ToString() == "-")
            {
                Delete();
                NumberString   = "-";
                BlockMain.Text = NumberString;
            }
            else
            if (!CantDo())
            {
                if (((BlockMain.Text == "-") || (String.IsNullOrEmpty(BlockMain.Text))) && (String.IsNullOrEmpty(Block1.Text)))
                {
                    NumberString = "0";
                    State        = Statee.first;
                }
                if (State == Statee.first)
                {
                    Block1.Text = System.Convert.ToString(System.Convert.ToDouble(NumberString));
                    NumResult   = System.Convert.ToDouble(NumberString);
                    State       = Statee.second;
                }
                if (Block2.Text != "")
                {
                    double Num1 = System.Convert.ToDouble(Block1.Text);
                    double Num2 = System.Convert.ToDouble(Block2.Text);
                    if ((System.Convert.ToString(System.Convert.ToDouble(Block2.Text)) == "0") && (BlockDo.Text == "÷"))
                    {
                        BlockMain.Text = Invalid;
                        Block2.Text    = "0";
                        State          = Statee.result;
                    }
                    else
                    {
                        Counter(Num1, Num2);
                        Block2.Text = null;
                        Block1.Text = System.Convert.ToString(NumResult);
                        State       = Statee.second;
                    }
                }
                if (((State == Statee.result) && !CantDo()) || (BlockMain.Text != ""))
                {
                    Block1.Text = NumResult.ToString();
                    Block2.Text = null;
                    State       = Statee.second;
                }

                if (State != Statee.result)
                {
                    BlockMain.Text = null;
                    NumberString   = "0";
                    BlockDo.Text   = (sender as Button).Content.ToString();
                }
            }
        }