Ejemplo n.º 1
0
        public void Update()
        {
            try
            {
                double[] dp;
                bool found = false;
                e = new ShotEventArgs();
                int tim = 0;
                for (int i = 0; i < 3000; i += 30)
                {
                    dp = GetPosAtTime(i);

                    if (ground.IsPixel((int)dp[0], (int)dp[1]) == true)
                    {
                        //e.User = user;
                        e.angle = (int)ang;
                        e.cx = (int)dp[0];
                        e.cy = (int)dp[1];
                        e.look = look;
                        e.power = (int)power;
                        e.xb = (int)xb;
                        e.yb = (int)yb;
                        e.xf = (int)x;
                        e.yf = (int)y;
                        e.ax = (int)ax;
                        e.ay = (int)ay;
                        e.col = true;
                        e.time = i;
                        found = true;
                        Shot(this, e);
                        ground.AddGroundHole((int)dp[0], (int)dp[1], 36, 40);
                        break;
                    }
                    tim = i;
                }
                if (!found)
                {
                    //e.User = user;
                    e.angle = (int)ang;
                    e.cx = 0;
                    e.cy = 0;
                    e.look = look;
                    e.power = (int)power;
                    e.xb = (int)xb;
                    e.yb = (int)yb;
                    e.xf = (int)x;
                    e.yf = (int)y;
                    e.ax = (int)ax;
                    e.ay = (int)ay;
                    e.col = false;
                    e.time = tim;
                    Shot(this, e);
                }
            }
            catch (Exception ex)
            {
                LogConsole.Show(LogType.ERROR, ex.ToString());
            }
        }
Ejemplo n.º 2
0
        public void Update()
        {
            try
            {
                double[] dp;
                bool     found = false;
                e = new ShotEventArgs();
                int tim = 0;
                for (int i = 0; i < 3000; i += 30)
                {
                    dp = GetPosAtTime(i);

                    if (ground.IsPixel((int)dp[0], (int)dp[1]) == true)
                    {
                        //e.User = user;
                        e.angle = (int)ang;
                        e.cx    = (int)dp[0];
                        e.cy    = (int)dp[1];
                        e.look  = look;
                        e.power = (int)power;
                        e.xb    = (int)xb;
                        e.yb    = (int)yb;
                        e.xf    = (int)x;
                        e.yf    = (int)y;
                        e.ax    = (int)ax;
                        e.ay    = (int)ay;
                        e.col   = true;
                        e.time  = i;
                        found   = true;
                        Shot(this, e);
                        ground.AddGroundHole((int)dp[0], (int)dp[1], 36, 40);
                        break;
                    }
                    tim = i;
                }
                if (!found)
                {
                    //e.User = user;
                    e.angle = (int)ang;
                    e.cx    = 0;
                    e.cy    = 0;
                    e.look  = look;
                    e.power = (int)power;
                    e.xb    = (int)xb;
                    e.yb    = (int)yb;
                    e.xf    = (int)x;
                    e.yf    = (int)y;
                    e.ax    = (int)ax;
                    e.ay    = (int)ay;
                    e.col   = false;
                    e.time  = tim;
                    Shot(this, e);
                }
            }
            catch (Exception ex)
            {
                LogConsole.Show(LogType.ERROR, ex.ToString());
            }
        }
Ejemplo n.º 3
0
 public void SetShot(UserClass _user, double _ang, double _power, double _ax, double _ay, double _x, double _y, int _look)
 {
     ang = _ang;
     power = _power;
     ax = _ax;
     ay = _ay;
     x = _x - 23;
     y = _y - 24;
     xb = _x;
     yb = _y;
     vec = Vector(_ang, _power);
     look = _look;
     user = _user;
     e = null;
 }
Ejemplo n.º 4
0
 public void SetShot(UserClass _user, double _ang, double _power, double _ax, double _ay, double _x, double _y, int _look)
 {
     ang   = _ang;
     power = _power;
     ax    = _ax;
     ay    = _ay;
     x     = _x - 23;
     y     = _y - 24;
     xb    = _x;
     yb    = _y;
     vec   = Vector(_ang, _power);
     look  = _look;
     user  = _user;
     e     = null;
 }
Ejemplo n.º 5
0
 //-----------------------------------------------------------------------------------------------------
 public void cshot_Shot(object o, ShotEventArgs e)
 {
     try
     {
         StringBuilder sb = new StringBuilder();
         StringWriter sw = new StringWriter(sb);
         using (JsonWriter writer = new JsonTextWriter(sw))
         {
             writer.Formatting = Formatting.None;
             writer.WriteStartArray();
             writer.WriteValue((int)ServerOpcode.play); //8
             writer.WriteStartArray();
             if (e.User.Position == 0)
             {
                 writer.WriteValue(1); //2 - next_turn_number
             }
             else
             {
                 writer.WriteValue(0); //2 - next_turn_number
             }
             writer.WriteValue(e.User.Position); //0 - player_number
             writer.WriteValue(e.xb); //1022 - x
             writer.WriteValue(e.yb); //121 - y
             writer.WriteValue(e.look); //1 - look
             writer.WriteValue(1); //845 - delay
             //writer.WriteValue(0); //1 - next_turn_of_player
             if (e.User.Position == 0)
             {
                 writer.WriteValue(1); //2 - next_turn_of_player
             }
             else
             {
                 writer.WriteValue(0); //2 - next_turn_of_player
             }
             writer.WriteStartArray();
             writer.WriteEndArray();
             writer.WriteValue(799); //799 - thor_x
             writer.WriteValue(-420); //-420 - thor_y
             writer.WriteValue(0); //24 - thor_angle
             writer.WriteValue(40); //0 - thor_damage
             writer.WriteValue(1); //33
             writer.WriteValue(0); //0
             writer.WriteValue(234); //326
             writer.WriteStartArray();
             writer.WriteStartObject();
             writer.WritePropertyName("start");
             writer.WriteStartObject();
             writer.WritePropertyName("x");
             writer.WriteValue(e.xf);    //1042
             writer.WritePropertyName("y");
             writer.WriteValue(e.yf);    //95
             writer.WritePropertyName("ang");
             writer.WriteValue(e.angle);    //24
             writer.WritePropertyName("power");
             writer.WriteValue(e.power);//101
             writer.WritePropertyName("ax");
             writer.WriteValue(e.ax);  //0
             writer.WritePropertyName("ay");
             writer.WriteValue(e.ay);  //398
             writer.WriteEndObject();
             writer.WritePropertyName("exp");
             writer.WriteValue(0);    //0
             writer.WritePropertyName("img");
             writer.WriteValue(0);    //0
             writer.WritePropertyName("time");
             writer.WriteValue(e.time); //1340
             //"hole":[887,95,60,40],"damages":[]}],150]
             if (e.col == true)
             {
                 writer.WritePropertyName("hole");
                 writer.WriteStartArray();
                 writer.WriteValue(e.cx);    //x hole
                 writer.WriteValue(e.cy);    //y hole
                 writer.WriteValue(36);    //w
                 writer.WriteValue(40);    //h
                 writer.WriteEndArray();
                 writer.WritePropertyName("damages");
                 writer.WriteStartArray();
                 writer.WriteEndArray();
             }
             writer.WriteEndObject();
             writer.WriteEndArray();
             writer.WriteValue(150);
             writer.WriteEndArray();
             writer.WriteEndArray();
         }
         SendAll(sb.ToString());
     }
     catch (Exception ex)
     {
         LogConsole.Show(LogType.ERROR, ex.ToString());
     }
 }