Esempio n. 1
0
        //painting field
        private void Paint()
        {
            InsideField.Children.Clear();
            if (XSizeTB.Text != "" && YSizeTB.Text != "")
            {
                int x = SCM.Int32(XSizeTB);
                int y = SCM.Int32(YSizeTB);

                graphicTBs = new TextBox[x, y];

                CurrentCellSize = (Field.ActualWidth - otstup) / x;
                if ((Field.ActualHeight - otstup) / y < CurrentCellSize)
                {
                    CurrentCellSize = (Field.ActualHeight - otstup) / y;
                }

                InsideField.Width  = CurrentCellSize * x;
                InsideField.Height = CurrentCellSize * y;

                for (int i = 0; i < x; i++)
                {
                    for (int j = 0; j < y; j++)
                    {
                        AddRgl(i, j);
                        AddTB(i, j);
                    }
                }
            }
        }
Esempio n. 2
0
        private void Player2CurrentChip_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            cell a = game.GetPlayer2CurrentState(Convert.ToInt32(Player2CurrentChipLB.SelectedValue));

            XPlayer2TB.Text = (SCM.InvX(a.X)).ToString();
            YPlayer2TB.Text = (SCM.InvY(a.Y)).ToString();
        }  //check
Esempio n. 3
0
 private void XYEndTB_TextChanged(object sender, TextChangedEventArgs e)
 {
     SCM.TBTreating(XEndTB, XSizeTB);
     SCM.TBTreating(YEndTB, YSizeTB);
     if (XEndTB.Text != "" && YEndTB.Text != "")
     {
         game.End = new cell(SCM.X(XEndTB), SCM.Y(YEndTB));
     }
 }
Esempio n. 4
0
        //logic events begin
        private void Player1TB_TextChanged(object sender, TextChangedEventArgs e)
        {
            SCM.TBTreating(XPlayer1TB, game.MapSizeX);
            SCM.TBTreating(YPlayer1TB, game.MapSizeY);
            SCM.TBTreating(LifePlayer1TB, MaxPlayer1Life);

            if (XPlayer1TB.Text != "" && YPlayer1TB.Text != "" && LifePlayer1TB.Text != "")
            {
                game.InitPlayer1(SCM.X(XPlayer1TB), SCM.Y(YPlayer1TB), SCM.Int32(LifePlayer1TB));
            }
        }
Esempio n. 5
0
 private void MapTB_TextChanged(object sender, TextChangedEventArgs e)
 {
     SCM.TBTreating(XMapTB, XSizeTB);
     SCM.TBTreating(YMapTB, YSizeTB);
     if (XMapTB.Text != "" && YMapTB.Text != "")
     {
         CostMapTB.Text = game.GetMapCell(SCM.X(XMapTB), SCM.Y(YMapTB)).Price.ToString();
     }
     if (XMapTB.Text == "" && YMapTB.Text == "")
     {
         CostMapTB.Clear();
     }
 }
Esempio n. 6
0
        //logic events begin
        private void SizeTB_TextChanged(object sender, TextChangedEventArgs e)
        {
            SCM.TBTreating(XSizeTB, MaxX);
            SCM.TBTreating(YSizeTB, MaxY);

            if (XSizeTB.Text != "" && YSizeTB.Text != "")
            {
                game.InitGameMap(SCM.Int32(XSizeTB), SCM.Int32(YSizeTB));
                Paint();
                CostMapTB.Text = "1";
                YMapTB.Text    = "1";
                XMapTB.Text    = "1";
            }
        }
Esempio n. 7
0
 private void LifePlayer2TB_TextChanged(object sender, TextChangedEventArgs e)
 {
     if (XPlayer2TB.Text != "" && YPlayer2TB.Text != "")
     {
         SCM.TBTreating(LifePlayer2TB, MaxPlayer2Life);
         if (LifePlayer2TB.Text != "")
         {
             game.InitPlayer2(Convert.ToInt32(Player2CurrentChipLB.SelectedValue), SCM.X(XPlayer2TB), SCM.Y(YPlayer2TB), SCM.Int32(LifePlayer2TB));
         }
     }
     else
     {
         LifePlayer2TB.Clear();
     }
 }
Esempio n. 8
0
 private void CostMapTB_TextChanged(object sender, TextChangedEventArgs e)
 {
     if (XMapTB.Text != "" && YMapTB.Text != "")
     {
         SCM.TBTreating(CostMapTB, MaxCost);
         if (CostMapTB.Text != "")
         {
             game.InitMapCell(SCM.X(XMapTB), SCM.Y(YMapTB), SCM.Int32(CostMapTB));
             graphicTBs[SCM.X(XMapTB), SCM.Y(YMapTB)].Text = CostMapTB.Text;
         }
     }
     else
     {
         CostMapTB.Clear();
     }
 }
Esempio n. 9
0
        }  //check

        private void XYPlayer2TB_TextChanged(object sender, TextChangedEventArgs e)
        {
            if (Player2CurrentChipLB.SelectedValue == null)
            {
                XPlayer2TB.Clear();
                YPlayer2TB.Clear();
            }
            else
            {
                SCM.TBTreating(XPlayer2TB, game.MapSizeX);
                SCM.TBTreating(YPlayer2TB, game.MapSizeY);
            }
            if (XPlayer2TB.Text == "" || YPlayer2TB.Text == "")
            {
                LifePlayer2TB.Clear();
            }
        }
Esempio n. 10
0
        private void graphicTextBoxes_TextChanged(object sender, TextChangedEventArgs e)
        {
            TextBox currentTextBox = sender as TextBox;

            if (currentTextBox != null)
            {
                SCM.TBTreating(currentTextBox, MaxCost);
                if (currentTextBox.Text != "")
                {
                    string[] indexes = currentTextBox.Name.Split('_', 'a');
                    int      x       = Convert.ToInt32(indexes[1]);
                    int      y       = Convert.ToInt32(indexes[2]);
                    game.InitMapCell(x, y, SCM.Int32(currentTextBox));
                    if (XMapTB.Text == indexes[1] && YMapTB.Text == indexes[2])
                    {
                        CostMapTB.Text = game.GetMapCell(x, y).Price.ToString();
                    }
                }
            }
        }
Esempio n. 11
0
        //Load map
        private void Load(string name)
        {
            FileStream   a   = new FileStream(path + name + ".txt", FileMode.Open);
            StreamReader str = new StreamReader(a);

            string[] ints = str.ReadLine().Split(' ');
            ints         = str.ReadLine().Split(' ');
            XSizeTB.Text = ints[0];
            YSizeTB.Text = ints[1];
            for (int i = SCM.Y(YSizeTB); i >= 0; i--)
            {
                ints = str.ReadLine().Split(' ');
                for (int j = 0; j < SCM.Int32(XSizeTB); j++)
                {
                    game.InitMapCell(i, j, Convert.ToInt32(ints[j]));
                }
            }
            XMapTB.Text = "1";
            YMapTB.Text = "1";
            ints        = str.ReadLine().Split();
            XEndTB.Text = ints[0];
            YEndTB.Text = ints[1];
        }