예제 #1
0
 private void Draw_Tank(Tank otherTank)
 {
     otherTank.Draw(this);
 }
예제 #2
0
        public void Execute(object _currentData)
        {
            string s = _currentData as string;

            int[] b = s.Split(';').Select(int.Parse).ToArray();
            if (b[0] == 7)
            {
                networker.Send("8;" + _player[0].x[0].ToString() + ";" + _player[0].y[0].ToString()
                               + ";" + _player[0].Tank_Current_Status.ToString() + ";" + _player.IndexOf(_player[0]));
            }
            if (b[1] == 0)
            {
                if (b[0] == 0)
                {
                    _player[b[2]] = tank;
                    if (b[2] != 2)
                    {
                        _player[2] = null;
                    }
                }

                if (b[0] == 6)
                {
                    Tank otherTank = new Tank();
                    Draw_Tank(otherTank);

                    foreach (Tank item in _player)
                    {
                        if (item == null)
                        {
                            _player[_player.IndexOf(item)] = otherTank;
                            return;
                        }
                    }
                }
                if (b[0] == 1)
                {
                    _player[0].Go_Up(this, map);
                }
                if (b[0] == 2)
                {
                    _player[0].Go_Down(this, map);
                }
                if (b[0] == 3)
                {
                    _player[0].Go_Left(this, map);
                }
                if (b[0] == 4)
                {
                    _player[0].Go_Right(this, map);
                }
                if (b[0] == 5)
                {
                    this.Invoke((MethodInvoker) delegate
                    {
                        _player[0].Shot(this);
                        Bullet bull = new Bullet(_player[0], this);
                        bull.X_Map(map);
                        map.Wall_damged(bull);
                        bull.fly(this);
                    });
                }
            }
            if (b[1] == 1)
            {
                if (b[0] == 0)
                {
                    _player[b[2]] = tank;
                    _player[2]    = null;
                }
                if (b[0] == 6)
                {
                    Tank otherTank = new Tank();
                    Draw_Tank(otherTank);
                    foreach (Tank item in _player)
                    {
                        if (item == null)
                        {
                            _player.Add(otherTank);
                            return;
                        }
                    }
                }
                if (b[0] == 1)
                {
                    _player[1].Go_Up(this, map);
                }
                if (b[0] == 2)
                {
                    _player[1].Go_Down(this, map);
                }
                if (b[0] == 3)
                {
                    _player[1].Go_Left(this, map);
                }
                if (b[0] == 4)
                {
                    _player[1].Go_Right(this, map);
                }
                if (b[0] == 5)
                {
                    this.Invoke((MethodInvoker) delegate
                    {
                        _player[1].Shot(this);
                        Bullet bull = new Bullet(_player[1], this);
                        bull.X_Map(map);
                        map.Wall_damged(bull);
                        bull.fly(this);
                    });
                }
                if (b[0] == 8)
                {
                    _player[0]      = new Tank();
                    _player[0].x[0] = b[2];
                    _player[0].y[0] = b[3];
                    if (b[4] == 1)
                    {
                        _player[0].Tank_Current_Status = 1;
                        _player[0].x[1] = b[2] - 1;
                        _player[0].y[1] = b[3] + 1;
                        _player[0].x[2] = b[2];
                        _player[0].y[2] = b[3] + 1;
                        _player[0].x[3] = b[2] + 1;
                        _player[0].y[3] = b[3] + 1;
                        _player[0].x[4] = b[2] - 1;
                        _player[0].y[4] = b[3] + 2;
                        _player[0].x[5] = b[2] + 1;
                        _player[0].y[5] = b[3] + 2;
                    }
                    if (b[4] == 2)
                    {
                        _player[0].Tank_Current_Status = 2;
                        _player[0].x[1] = b[2] + 1;
                        _player[0].y[1] = b[3] - 1;
                        _player[0].x[2] = b[2];
                        _player[0].y[2] = b[3] - 1;
                        _player[0].x[3] = b[2] - 1;
                        _player[0].y[3] = b[3] - 1;
                        _player[0].x[4] = b[2] + 1;
                        _player[0].y[4] = b[3] - 2;
                        _player[0].x[5] = b[2] - 1;
                        _player[0].y[5] = b[3] - 2;
                    }
                    if (b[4] == 3)
                    {
                        _player[0].Tank_Current_Status = 3;
                        _player[0].x[1] = b[2] + 1;
                        _player[0].y[1] = b[3] + 1;
                        _player[0].x[2] = b[2] + 1;
                        _player[0].y[2] = b[3];
                        _player[0].x[3] = b[2] + 1;
                        _player[0].y[3] = b[3] - 1;
                        _player[0].x[4] = b[2] + 2;
                        _player[0].y[4] = b[3] + 1;
                        _player[0].x[5] = b[2] + 2;
                        _player[0].y[5] = b[3] - 1;
                    }
                    if (b[4] == 4)
                    {
                        _player[0].Tank_Current_Status = 4;
                        _player[0].x[1] = b[2] - 1;
                        _player[0].y[1] = b[3] - 1;
                        _player[0].x[2] = b[2] - 1;
                        _player[0].y[2] = b[3];
                        _player[0].x[3] = b[2] - 1;
                        _player[0].y[3] = b[3] + 1;
                        _player[0].x[4] = b[2] - 2;
                        _player[0].y[4] = b[3] - 1;
                        _player[0].x[5] = b[2] - 2;
                        _player[0].y[5] = b[3] + 1;
                    }
                    Draw_Tank(_player[0]);
                }
            }
        }