Ejemplo n.º 1
0
        public void Save(SqlConnection conn)
        {
            //if (this.Error != null)
            //    this.Error = this.Error.Substring(0, 125);
            //if (this.Result != null)
            //    this.Result = this.Result.Substring(0, 125);
            string query = string.Format("insert into log (time,ip,func,args,result,error) values ('{0}','{1}','{2}','{3}','{4}','{5}')",
                                         MapServer.TimeString(DateTime.Now), this.IP, this.Function, this.Args, this.Result, this.Error);

            using (System.Data.SqlClient.SqlCommand command = new SqlCommand(query, conn))
            {
                command.ExecuteNonQuery();
            }
        }
Ejemplo n.º 2
0
        public static bool Random_Walk(MapServer.BaseObject obj, ref byte dir, ref short x, ref short y)
        {
            byte index = 0;
            x = obj.GetCurrentX();
            y = obj.GetCurrentY();
            while (true)
            {

                if (index >= 10) break;
                dir = Random_Dir();
                switch (dir)
                {
                    case LEFT_DOWN:
                        {
                            x -= 1;
                            y += 1;
                            break;
                        }
                    case LEFT:
                        {
                            x -= 1;
                            break;
                        }
                    case LEFT_UP:
                        {
                            x -= 1;
                            y -= 1;
                            break;
                        }
                    case UP:
                        {
                            y -= 1;
                            break;
                        }
                    case RIGHT_UP:
                        {
                            x += 1;
                            y -= 1;
                            break;
                        }
                    case RIGHT:
                        {
                            x += 1;
                            break;
                        }
                    case RIGHT_DOWN:
                        {
                            x += 1;
                            y += 1;
                            break;
                        }
                    case DOWN:
                        {
                            y += 1;
                            break;
                        }

                }
                if (obj.GetGameMap().CanMove(x, y))
                {
                    return true;
                }
                index++;
            }
            return false;
        }
Ejemplo n.º 3
0
        //取下一个坐标点--
        public static bool GetNexPoint(MapServer.BaseObject obj, ref short x, ref short y)
        {
            byte dir = obj.GetDir();
            short srcx = obj.GetCurrentX();
            short srcy = obj.GetCurrentY();

            x = (short)(srcx + _DELTA_X[dir]);
            y = (short)(srcy + _DELTA_Y[dir]);

            if (!obj.GetGameMap().CanMove(x, y)) return false; //不能行走
            if (x == srcx && y == srcy) return false;
            return true;
        }