Exemple #1
0
        /// <summary>
        /// Performs a task until a condition is met
        /// </summary>
        /// <param name="action">The action to be executed</param>
        /// <param name="condition">The condition for this task to stop</param>
        /// <param name="every">Optional: The time (in seconds) to wait between executions</param>
        /// <param name="startAfter">Optional: The time (in seconds) to wait before starting the task</param>
        /// <param name="useLateUpdate">Optional: If true, the task will be executed on LateUpdate instead of Update</param>
        /// <param name="timeout">Optional: A maximum duration (in seconds) for this task. If set, the task will stop even if the condition isn't met. Note that the action won't be executed.</param>
        /// <returns>The STask. You can save this task to stop it before it's finished and to subscribe to events such us OnComplete</returns>
        public static STask DoUntil(SAction action, SCondition condition, float every = 0, float startAfter = 0, bool useLateUpdate = false, float timeout = -1)
        {
            STask task = new STask(TaskType.Until, action, after: startAfter, condition, every, useLateUpdate: useLateUpdate, timeout: timeout);

            AddTask(task);
            return(task);
        }
        private static string GetForAll(string tablename,
                                        string key, string name, string nameField = "Name")
        {
            var nameValue = key.IsNullOrEmpty() ? name : key;

            return(SAction.Select(tablename, nameField.ToLikeWhere(nameValue), "Name").ToJson());
        }
Exemple #3
0
        /// <summary>
        /// Performs a task when a condition is met
        /// </summary>
        /// <param name="action">The action to be executed</param>
        /// <param name="condition">The condition for this task to stop</param>
        /// <param name="startAfter">Optional: The time (in seconds) to wait before starting the task</param>
        /// <returns>The STask. You can save this task to stop it before it's finished and to subscribe to events such us OnComplete</returns>
        public static STask DoWhen(SAction action, SCondition condition, float startAfter = 0)
        {
            STask task = new STask(TaskType.OnCondition, action, startAfter, condition);

            AddTask(task);
            return(task);
        }
Exemple #4
0
        /// <summary>
        /// Performs a task every few seconds until manually stopped
        /// </summary>
        /// <param name="action">The action to be executed</param>
        /// <param name="every">The time (in seconds) to wait between executions</param>
        /// <param name="startAfter">Optional: The time (in seconds) to wait before starting the task</param>
        /// <param name="useLateUpdate">Optional: If true, the task will be executed on LateUpdate instead of Update</param>
        /// <returns>The STask. You can save this task to stop it before it's finished and to subscribe to events such us OnComplete</returns>
        public static STask DoRepeating(SAction action, float every, float startAfter = 0, bool useLateUpdate = false)
        {
            STask task = new STask(TaskType.Looped, action, startAfter, null, every, useLateUpdate: useLateUpdate);

            AddTask(task);
            return(task);
        }
Exemple #5
0
        /// <summary>
        /// Schedules a task so it's executed after some time
        /// </summary>
        /// <param name="action">The action to be executed</param>
        /// <param name="after">The time (in seconds) to wait before executing the task</param>
        /// <param name="completeAfterLastFrame">Optional: If true, OnComplete will be called one frame after the action was executed</param>
        /// <returns>The STask. You can save this task to stop it before it's finished and to subscribe to events such us OnComplete</returns>
        public static STask Do(SAction action, float after, bool completeAfterLastFrame = false)
        {
            STask task = new STask(TaskType.Simple, action, after, completeAfterLastFrame: completeAfterLastFrame);

            AddTask(task);
            return(task);
        }
Exemple #6
0
        /// <summary>
        /// Performs a task after a given number of frames has passed
        /// </summary>
        /// <param name="action">The action to be executed</param>
        /// <param name="frames">The number of frames to wait</param>
        /// <returns>The STask. You can save this task to stop it before it's finished and to subscribe to events such us OnComplete</returns>
        public static STask DoAfterFrames(SAction action, int frames)
        {
            STask task = null;

            task = new STask(TaskType.OnCondition, action, condition: () => task.ElapsedFrames == frames);
            AddTask(task);
            return(task);
        }
 public static string GetDept(string key, string id, bool isDept, string pid)
 {
     var where = "isUsing=1" +
                 " and " + "name".ToLikeWhere(key) +
                 " and " + "id".ToWhere(id) +
                 " and " + "pId".ToWhere(pid);
     where += " and " + (isDept ? "id>1000 and id<999999" : "id>1000000");
     return(SAction.Select("SysDepartment", where, "id", "name").ToJson().Replace(" 00:00:00", ""));
 }
Exemple #8
0
        public void CentralizeOoO()
        {
            while (true)
            {
                foreach (Bot b in Bots)
                {
                    if (b.ActionList.Count != 0)
                    {
                        SAction CurAction = b.ActionList[0];

                        b.ActionList.Sort();
                        b.TargetList.Sort();
                        b.HealList.Sort();
                        if (b.ActionList[0] != CurAction || (b.TargetList.Count != 0 && b.ActionList[0].Priority < BotHub.AgroPriority) || (b.HealList.Count != 0 && b.ActionList[0].Priority < BotHub.HealPriority))
                        {
                            SendConsole("Changing current action", ConsoleLvl.BotHub, b);
                            b.breakCurAction();
                        }
                        else if (CurAction.Action == BotAction.Attack)
                        {
                            if (b.TargetList[0].Target != b.Cible)
                            {
                                SendConsole("Changing current target", ConsoleLvl.BotHub, b);
                                b.breakCurAction();
                            }
                        }
                        else if (CurAction.Action == BotAction.Heal)
                        {
                            if (b.HealList[0].Target != b.Cible)
                            {
                                SendConsole("Changing current heal target", ConsoleLvl.BotHub, b);
                                b.breakCurAction();
                            }
                        }
                        else if (CurAction.Action == BotAction.AttackMain)
                        {
                            if (b.MainTargetList.Peek().Target != b.Cible)
                            {
                                SendConsole("Changing current target", ConsoleLvl.BotHub, b);
                                b.breakCurAction();
                            }
                        }
                        else if (CurAction.Action == BotAction.GoToLocation)
                        {
                            if (!CurAction.Location.Equals(b.ActionList[0].Location))
                            {
                                SendConsole("Changing current location", ConsoleLvl.BotHub, b);
                                b.breakCurAction();
                            }
                        }
                        Thread.Sleep(10);
                    }
                }
                Thread.Sleep(150);
            }
        }
 public static string GetPersonal(string key, string personalIdCard)
 {
     string where = "PersonalIdCard".ToInWhere(personalIdCard);
     if (key.IsNotNullEmpty())
     {
         where += " and IsUsing=1 and " +
                  "fullname".ToLikeWhere(key);
     }
     return(SAction.Select("Personal", where,
                           "PersonalIdCard", "Fullname").ToJson());
 }
Exemple #10
0
        private void GenerateWater()
        {
            floor.layer = 4; //Water layer

            //Water collider
            GameObject fcollider = new GameObject("water-collider");

            fcollider.transform.SetParent(floor.transform);
            fcollider.transform.position = floor.transform.position;
            fcollider.isStatic           = true;
            fcollider.layer = 14; //Water wall layer

            MeshRenderer crender = fcollider.AddComponent <MeshRenderer>();
            MeshFilter   cmesh   = fcollider.AddComponent <MeshFilter>();

            crender.enabled = false;

            cmesh.sharedMesh = new Mesh();
            CreateFloorMesh(cmesh.sharedMesh, 5f);
            MeshCollider ccollide = fcollider.AddComponent <MeshCollider>();

            ccollide.convex = true;

            //Drink Selectable
            GameObject fselect = new GameObject("water-drink");

            fselect.transform.SetParent(floor.transform);
            fselect.transform.position = floor.transform.position;
            fselect.layer = floor.layer;

            MeshRenderer srender = fselect.AddComponent <MeshRenderer>();
            MeshFilter   smesh   = fselect.AddComponent <MeshFilter>();

            srender.enabled = false;

            smesh.sharedMesh = new Mesh();
            CreateFloorMesh(smesh.sharedMesh, 1f, -1f);
            MeshCollider scollide = fselect.AddComponent <MeshCollider>();

            scollide.convex    = true;
            scollide.isTrigger = true;

            Selectable selectable = fselect.AddComponent <Selectable>();

            selectable.type = SelectableType.InteractSurface;

            if (WorldGenerator.Get())
            {
                SAction action = WorldGenerator.Get().water_action;
                selectable.actions = new SAction[] { action };
                GroupData group = WorldGenerator.Get().water_group;
                selectable.groups = new GroupData[] { group };
            }
        }
Exemple #11
0
        public void CAction(GSSession session, CAction message)
        {
            session.Player.Character.Direction = message.Dir;
            var ans = new SAction((ushort)session.Player.Account.ID, message.Dir, message.ActionNumber, message.Target);

            session.SendAsync(ans);

            foreach (var plr in session.Player.Character.PlayersVP)
            {
                plr.Session.SendAsync(ans);
            }
        }
Exemple #12
0
        /// <summary>
        /// Schedules a task so it's executed after some time
        /// </summary>
        /// <param name="action">The action to be executed</param>
        /// <param name="after">The time (in seconds) to wait before executing the task</param>
        /// <param name="updateType">Optional: The update method this task should use (Update/LateUpdate/FixedUpdate)</param>
        /// <returns>The STask. You can save this task to stop it before it's finished and to subscribe to events such us OnComplete</returns>
        public static DoTask Do(SAction action, float after, UpdateType updateType = UpdateType.Update)
        {
            STaskSettings settings = new STaskSettings()
            {
                action = action,
                delay  = after,
            };

            DoTask task = new DoTask(settings);

            AddTask(task, updateType);
            return(task);
        }
Exemple #13
0
        public STask(STaskSettings settings)
        {
            Delay = settings.delay;

            this.action      = settings.action;
            this.maxDuration = settings.maxDuration;

            _elapsedTime = 0;
            _timeOfStart = 0;

            hasMaxDuration     = maxDuration > 0;
            _isWaitingForDelay = Delay > 0;
        }
Exemple #14
0
        /// <summary>
        /// Performs a task when a condition is met
        /// </summary>
        /// <param name="action">The action to be executed</param>
        /// <param name="condition">The condition for this task to stop</param>
        /// <param name="startAfter">Optional: The time (in seconds) to wait before starting the task</param>
        /// <param name="updateType">Optional: The update method this task should use (Update/LateUpdate/FixedUpdate)</param>
        /// <returns>The STask. You can save this task to stop it before it's finished and to subscribe to events such us OnComplete</returns>
        public static DoWhenTask DoWhen(SAction action, SCondition condition, float startAfter = 0, UpdateType updateType = UpdateType.Update)
        {
            STaskSettings settings = new STaskSettings()
            {
                action    = action,
                condition = condition,
                delay     = startAfter,
            };

            DoWhenTask task = new DoWhenTask(settings);

            AddTask(task, updateType);
            return(task);
        }
Exemple #15
0
        /// <summary>
        /// Performs a task after a given number of frames has passed
        /// </summary>
        /// <param name="action">The action to be executed</param>
        /// <param name="frames">The number of frames to wait</param>
        /// <param name="startAfter">Optional: The time (in seconds) to wait before starting to count the frames</param>
        /// <param name="updateType">Optional: The update method this task should use (Update/LateUpdate/FixedUpdate)</param>
        /// <returns>The STask. You can save this task to stop it before it's finished and to subscribe to events such us OnComplete</returns>
        public static DoAfterFramesTask DoAfterFrames(SAction action, int frames, float startAfter = 0, UpdateType updateType = UpdateType.Update)
        {
            STaskSettings settings = new STaskSettings()
            {
                action       = action,
                targetFrames = frames,
                delay        = startAfter,
            };

            DoAfterFramesTask task = new DoAfterFramesTask(settings);

            AddTask(task, updateType);
            return(task);
        }
Exemple #16
0
        /// <summary>
        /// Performs a task every few seconds until manually stopped
        /// </summary>
        /// <param name="action">The action to be executed</param>
        /// <param name="every">The time (in seconds) to wait between executions</param>
        /// <param name="startAfter">Optional: The time (in seconds) to wait before starting the task</param>
        /// <param name="updateType">Optional: The update method this task should use (Update/LateUpdate/FixedUpdate)</param>
        /// <returns>The STask. You can save this task to stop it before it's finished and to subscribe to events such us OnComplete</returns>
        public static DoRepeatingTask DoRepeating(SAction action, float every, float startAfter = 0, float maxDuration = -1, UpdateType updateType = UpdateType.Update)
        {
            STaskSettings settings = new STaskSettings()
            {
                action      = action,
                frequency   = every,
                delay       = startAfter,
                maxDuration = maxDuration,
            };

            DoRepeatingTask task = new DoRepeatingTask(settings);

            AddTask(task, updateType);
            return(task);
        }
Exemple #17
0
        /// <summary>
        /// Performs a task until a condition is met
        /// </summary>
        /// <param name="action">The action to be executed</param>
        /// <param name="condition">The condition for this task to stop</param>
        /// <param name="every">Optional: The time (in seconds) to wait between executions</param>
        /// <param name="startAfter">Optional: The time (in seconds) to wait before starting the task</param>
        /// <param name="updateType">Optional: The update method this task should use (Update/LateUpdate/FixedUpdate)</param>
        /// <param name="timeout">Optional: A maximum duration (in seconds) for this task. If set, the task will stop even if the condition isn't met. Note that the action won't be executed.</param>
        /// <returns>The STask. You can save this task to stop it before it's finished and to subscribe to events such us OnComplete</returns>
        public static DoUntilTask DoUntil(SAction action, SCondition condition, float every = 0, float startAfter = 0, float timeout = -1, UpdateType updateType = UpdateType.Update)
        {
            STaskSettings settings = new STaskSettings()
            {
                action      = action,
                condition   = condition,
                frequency   = every,
                delay       = startAfter,
                maxDuration = timeout,
            };

            DoUntilTask task = new DoUntilTask(settings);

            AddTask(task, updateType);
            return(task);
        }
    void Start()
    {
        _action          = new SAction(this);
        _action.Duration = 2;
        _action.OverTime = ActionToPerformOverTime;
        _action.OnEnd    = ActionToPerformOnEnd;
        _action.Start();

        // === OR === //

        _action = new SAction(this)
        {
            Duration = 2,
            OverTime = (progress) => { Debug.Log("The SAction is completed at " + (progress * 100) + "%"); },
            OnEnd    = () => { Debug.Log("The SAction has ended"); }
        };
        _action.Start();
    }
Exemple #19
0
        public STask(TaskType type, SAction action, float after = 0, SCondition condition = null, float every = -1, bool completeAfterLastFrame = false, bool useLateUpdate = false, float timeout = -1)
        {
            this.action    = action;
            this._after    = after;
            this.condition = condition;
            this._every    = every;
            this._taskType = type;
            this._completeAfterLastFrame = completeAfterLastFrame;
            this._useLateUpdate          = useLateUpdate;
            this._timeout = timeout;

            _isCompletionScheduled = false;
            _isLooped     = type == TaskType.Until || type == TaskType.Looped;
            _loopStarted  = false;
            IsDone        = false;
            ElapsedTime   = 0;
            ElapsedFrames = 0;
        }
Exemple #20
0
        private static string GetResult(NameValueCollection queryString,
                                        int page, MDataTable result, string colName)
        {
            if (page != 0 || queryString["page"].IsNullOrEmpty())
            {
                return(result.ToJson().Replace(" 00:00:00", ""));
            }

            //更改列名为中文名
            var colNames             = colName.Split('~');
            var shouldRemoveColNames = new List <string>();

            foreach (var column in result.Columns)
            {
                var dtColName = column.ColumnName;
                var index     = colNames.IndexOf(dtColName);
                if (index >= 0)
                {
                    column.ColumnName = colNames[index + 1];
                    continue;
                }
                shouldRemoveColNames.Add(dtColName);
            }

            //移除无需导出的列
            foreach (var removeColName in shouldRemoveColNames)
            {
                result.Columns.Remove(removeColName);
            }
            var tablename = result.TableName;
            var filename  = SAction.GetOneValue <string>("SysTableFilename", "tablename".ToWhere(tablename), "Filename");

            filename = filename.IsNullOrEmpty() ? tablename : filename;
            var workbook = result.ToWorkbook();

            workbook.SetSheetName(0, filename);
            ExportExcel.WriteExcel(workbook, filename);
            return(null);
        }
Exemple #21
0
        public static string Login(string username, string pwd)
        {
            var cookie = HttpContext.Current.Request.Cookies["login"];

            //if (cookie != null)
            //{
            //    return SJson.GetError("您已经登录,请退出登录。");
            //}
            if (SAction.Select("SysUser", "Username".ToWhere(username, false) + " and " + "Password".ToWhere(pwd, false), "ID").Rows.Count > 0)
            {
                if (cookie == null)
                {
                    cookie = new HttpCookie("login");
                }
                cookie.Values.Clear();
                cookie.Values.Add("username", username);
                HttpContext.Current.Response.Cookies.Clear();
                //cookie.Expires = DateTime.Now.AddHours(1);
                HttpContext.Current.Response.Cookies.Add(cookie);
                return(SJson.Success);
            }
            return(SJson.Error);
        }
    public void OnClickAction(SAction action)
    {
        if (visible)
        {
            if (action != null && select != null && character != null)
            {
                if (action.CanDoAction(character, select))
                {
                    action.DoAction(character, select);
                }
                Hide();
            }

            if (action != null && slot != null && character != null)
            {
                if (action.CanDoAction(character, slot))
                {
                    action.DoAction(character, slot);
                }
                Hide();
            }
        }
    }
Exemple #23
0
    public void OnClickAction(SAction action)
    {
        if (visible)
        {
            if (action != null && select != null && character != null)
            {
                character.FaceTorward(select.transform.position);
                if (action.CanDoAction(character, select))
                {
                    action.DoAction(character, select);
                }
                Hide();
            }

            if (action != null && slot != null && character != null)
            {
                if (action.CanDoAction(character, slot))
                {
                    action.DoAction(character, slot);
                }
                Hide();
            }
        }
    }
Exemple #24
0
 public static string Get()
 {
     return(SAction.Select("SysMenu", "Isusing=1").ToJson());
 }
 public void SetButton(SAction action)
 {
     this.action = action;
     title.text  = action.title;
     gameObject.SetActive(true);
 }
Exemple #26
0
 /// <summary>
 /// Subscribe a method that will be invoked when the task is killed
 /// </summary>
 /// <param name="action">The action to be invoked</param>
 /// <returns>The task</returns>
 public STask OnKill(SAction action)
 {
     onKill += action;
     return(this);
 }
Exemple #27
0
 /// <summary>
 /// Subscribe a method that will be invoked when the task is started (after the delay)
 /// </summary>
 /// <param name="action">The action to be invoked</param>
 /// <returns>The task</returns>
 public STask OnStart(SAction action)
 {
     onStart += action;
     return(this);
 }
Exemple #28
0
 /// <summary>
 /// Subscribe a method that will be invoked when the task is Updated (every frame)
 /// </summary>
 /// <param name="action">The action to be invoked</param>
 /// <returns>The task</returns>
 public STask OnUpdate(SAction action)
 {
     onUpdate += action;
     return(this);
 }
Exemple #29
0
 /// <summary>
 /// Subscribe a method that will be invoked when the task is complete
 /// </summary>
 /// <param name="action">The action to be invoked</param>
 /// <returns>The task</returns>
 public STask OnComplete(SAction action)
 {
     onComplete += action;
     return(this);
 }
Exemple #30
0
 public static string Delete(string table, string id)
 {
     //SAction.Delete(table, "ID".ToWhere(id, false));
     SAction.Update(table, "ID".ToWhere(id, false), "IsUsing", "0");
     return(SJson.Success);
 }