コード例 #1
0
        protected override GameAction PrepareNextActionOverride(out JobStatus progress)
        {
            var action = new WaitAction(m_turns);

            progress = JobStatus.Ok;
            return(action);
        }
コード例 #2
0
ファイル: REMLManager.cs プロジェクト: festeraddams/rahagame
        private BaseAction CreateAction(XmlReader reader, FulFillable lastToDoAble)
        {
            BaseAction action = null;

            var attributes  = GetAttributes(reader);
            var actionName  = attributes["name"];
            int repititions = 1;

            if (attributes.ContainsKey("repititions"))
            {
                repititions = int.Parse(attributes["repititions"]);
            }

            if (actionName == "hold")
            {
                action = new HoldAction(actionName, DB.StatisticType.action, null, double.Parse(attributes["value"]), lastToDoAble, settingsManager, feedback, PitchType.pitchDefault, repititions, statisticManager);
            }

            else if (actionName == "wait")
            {
                action = new WaitAction(actionName, DB.StatisticType.action, null, double.Parse(attributes["value"]), lastToDoAble, settingsManager, feedback, PitchType.pitchDefault, repititions, statisticManager);
            }

            if (lastToDoAble != null)
            {
                lastToDoAble.AddNext(action);
            }

            return(action);
        }
コード例 #3
0
        public override void Think(World world)
        {
            if (world.Player?.IsAlive ?? false)
            {
                var path = PathFinder.AStar(world.Level, Position, world.Player.Position);
                if (path.Any())
                {
                    var next = path.First();
                    var act  = world.Level.GetActorAt(next);
                    if (act == null)
                    {
                        Action = new MoveAction(this, (next - Position).Direction());
                    }
                    else if (act is Player)
                    {
                        Action = new AttackAction(this, act);
                    }
                }
            }

            if (Action == null)
            {
                Action = new WaitAction();
            }
        }
コード例 #4
0
    protected override void CopyTo(Action _destWarper)
    {
        WaitAction waitAction = _destWarper as WaitAction;

        waitAction.Duration = Duration;
        base.CopyTo(_destWarper);
    }
コード例 #5
0
 public override void FindNextState()
 {
     if (currentAction is WaitAction)
     {
         currentAction = new WalkAction(owner, TargetType.PLAYER);
     }
     else if (currentAction is WalkAction)
     {
         GameObject nearestPlayer = FindNearestPlayer();
         if ((nearestPlayer.transform.position - owner.transform.position).sqrMagnitude <= Mathf.Pow(0.22f, 2f))
         {
             currentAction = new AttackPrepareAction(owner, nearestPlayer, 0.4f);
         }
     }
     else if (currentAction is AttackPrepareAction)
     {
         if (currentAction.isOver)
         {
             AttackPrepareAction prevAction = currentAction as AttackPrepareAction;
             currentAction = new MeleeAttackAction(owner, prevAction.targetPosition, 1f, 2f);
         }
     }
     else if (currentAction is MeleeAttackAction)
     {
         if (currentAction.isOver)
         {
             owner.animator.SetTrigger("Idle");
             currentAction = new WaitAction();
         }
     }
 }
コード例 #6
0
 public void RegisterHeroDeath()
 {
     waitAction       = WaitAction.GAME_OVER;
     boss.currentMode = Boss.Mode.STORY;
     boss.moveTarget  = boss.transform.position;
     gameLostPanel.gameObject.SetActive(true);
 }
コード例 #7
0
        public void WaitActionConstructorTest()
        {
            WaitAction target = new WaitAction();

            Assert.IsTrue(target.IsTemplate, "The Property 'IsTemplate' is not properly initialized");
            Assert.IsFalse(target.IsSelected, "The Property 'IsSelected' is not properly initialized");
            Assert.AreEqual(55, target.Height, "The property 'Height' is not properly initialized.");
            Assert.AreEqual(15, target.AmountOfTime, "The property 'AmountOfTime' is not properly initialized.");
        }
コード例 #8
0
ファイル: Rulebook.cs プロジェクト: MoyTW/7DRL2021
        private static bool ResolveWait(WaitAction action, EncounterState state)
        {
            var defenderComponent = state.GetEntityById(action.ActorId).GetComponent <DefenderComponent>();

            if (defenderComponent != null)
            {
                defenderComponent.RestoreFooting();
            }
            return(true);
        }
コード例 #9
0
ファイル: Wait.cs プロジェクト: tomba/dwarrowdelf
        ActionState ProcessAction(WaitAction action)
        {
            if (this.ActionTicksUsed == 1)
                this.ActionTotalTicks = action.WaitTicks;

            if (this.ActionTicksUsed < this.ActionTotalTicks)
                return ActionState.Ok;
            else
                return ActionState.Done;
        }
コード例 #10
0
 private void ActivateSpeech(Character author, string speech)
 {
     messagePanel.gameObject.SetActive(true);
     authorText.text = GetCharacterLabel(author);
     currentSpeaker  = author;
     SetMessagePanelColor(author);
     speechText.text = "";
     speechString    = speech;
     AddToSpeechBubble();
     waitAction = WaitAction.SPEECH;
 }
コード例 #11
0
 public static void Wait(WaitCondition condition, WaitAction action)
 {
     if (condition())
     {
         action();
     }
     else
     {
         _waiting.Add(new Tuple <WaitCondition, WaitAction>(condition, action));
     }
 }
コード例 #12
0
        public void AmountOfTimeTest()
        {
            WaitAction target = new WaitAction();

            Assert.AreEqual(15, target.AmountOfTime);

            target.AmountOfTime = -10;
            Assert.AreEqual(1, target.AmountOfTime, "AmountOfTime can be set below 1");

            target.AmountOfTime = 700;
            Assert.AreEqual(600, target.AmountOfTime, "AmountOfTime can be set above 600");
        }
コード例 #13
0
        public void GetXMLActionTest()
        {
            WaitAction target = new WaitAction();

            target.AmountOfTime = 45;

            string expected = "<Action>\r\n<ElementType>CustomActions.WaitAction</ElementType>\r\n<AmountOfTime>" + target.AmountOfTime + "</AmountOfTime>\r\n</Action>";
            string actual;

            actual = target.GetXMLAction();
            Assert.AreEqual(expected, actual, "The method 'GetXMLAction' doesn't return the good string.");
        }
コード例 #14
0
    private WaitAction BuildWaitAction(ActionResult actionResult, EntityMap entityMap, GroundMap groundMap, bool logMessage = true)
    {
        if (logMessage)
        {
            actionResult.AppendMessage(new Message($"The {owner.name} is confused.  What should it do?", null));
        }
        var action = new WaitAction(owner.actor);

        actionResult.Success = true;
        action.SetActionResult(actionResult);
        return(action);
    }
コード例 #15
0
        /// <summary>
        /// Places a new order
        /// </summary>
        /// <param name="type">The type of the order</param>
        /// <param name="symbol">The symbol the order is for</param>
        /// <param name="amount">The amount of the order, positive for buying, negative for selling</param>
        /// <param name="groupId">Group id to assign to the order</param>
        /// <param name="clientOrderId">Client order id to assign to the order</param>
        /// <param name="price">Price of the order</param>
        /// <param name="priceTrailing">Trailing price of the order</param>
        /// <param name="priceAuxiliaryLimit">Auxiliary limit price of the order</param>
        /// <param name="priceOcoStop">Oco stop price of ther order</param>
        /// <param name="flags">Additional flags</param>
        /// <returns></returns>
        public async Task <CallResult <BitfinexOrder> > PlaceOrderAsync(OrderType type, string symbol, decimal amount, int?groupId = null, int?clientOrderId = null, decimal?price = null, decimal?priceTrailing = null, decimal?priceAuxiliaryLimit = null, decimal?priceOcoStop = null, OrderFlags?flags = null)
        {
            if (!CheckConnection())
            {
                return(new CallResult <BitfinexOrder>(null, new WebError("Socket needs to be started before placing an order")));
            }

            if (!authenticated)
            {
                return(new CallResult <BitfinexOrder>(null, new NoApiCredentialsError()));
            }

            log.Write(LogVerbosity.Info, "Going to place order");
            var order = new BitfinexNewOrder()
            {
                Amount              = amount,
                OrderType           = type,
                Symbol              = symbol,
                Price               = price,
                ClientOrderId       = clientOrderId,
                Flags               = flags,
                GroupId             = groupId,
                PriceAuxiliaryLimit = priceAuxiliaryLimit,
                PriceOCOStop        = priceOcoStop,
                PriceTrailing       = priceTrailing
            };

            var wrapper = new object[] { 0, "on", null, order };
            var data    = JsonConvert.SerializeObject(wrapper, new JsonSerializerSettings()
            {
                NullValueHandling = NullValueHandling.Ignore,
                Culture           = CultureInfo.InvariantCulture
            });

            BitfinexOrder orderConfirm = null;
            await Task.Run(() =>
            {
                var waitAction = new WaitAction <BitfinexOrder>();
                pendingOrders.Add(order, waitAction);
                Send(data);
                orderConfirm = waitAction.Wait(20000);
                pendingOrders.Remove(order);
            }).ConfigureAwait(false);

            if (orderConfirm != null)
            {
                log.Write(LogVerbosity.Info, "Order canceled");
            }

            return(new CallResult <BitfinexOrder>(orderConfirm, orderConfirm != null ? null : new ServerError("No confirmation received for placed order")));
        }
コード例 #16
0
ファイル: EntityBrain.cs プロジェクト: towa-hi/Block-Game
    ActionResult MobChooseNextAction(EntityState aEntityState)
    {
        Debug.Assert(aEntityState.mobData.HasValue);
        switch (aEntityState.mobData.Value.movementType)
        {
        case MoveTypeEnum.INANIMATE:
            WaitAction waitAction = new WaitAction(this.id);
            return(waitAction.GetActionResult(GM.boardManager.currentState));

        case MoveTypeEnum.PATROL:
            MoveAction moveForwardAction = new MoveAction(this.id, aEntityState.facing);
            // Debug.Log(this.id + " MobChooseNextAction on pos " + this.entityState.pos);
            ActionResult moveForwardResult = moveForwardAction.GetActionResult(GM.boardManager.currentState);
            if (moveForwardResult.boardState.HasValue)
            {
                return(moveForwardResult);
            }
            if (aEntityState.mobData.Value.canHop)
            {
                MoveAction   moveForwardUpAction = new MoveAction(this.id, aEntityState.facing + Vector2Int.up);
                ActionResult moveForwardUpResult = moveForwardUpAction.GetActionResult(GM.boardManager.currentState);
                if (moveForwardUpResult.boardState.HasValue)
                {
                    return(moveForwardUpResult);
                }
                MoveAction   moveForwardDownAction = new MoveAction(this.id, aEntityState.facing + Vector2Int.down);
                ActionResult moveForwardDownResult = moveForwardDownAction.GetActionResult(GM.boardManager.currentState);
                if (moveForwardDownResult.boardState.HasValue)
                {
                    return(moveForwardDownResult);
                }
            }
            TurnAction   turnAction = new TurnAction(this.id);
            ActionResult turnResult = turnAction.GetActionResult(GM.boardManager.currentState);
            Debug.Assert(turnResult.boardState.HasValue);
            return(turnResult);

        case MoveTypeEnum.FLY:
            throw new NotImplementedException();

        case MoveTypeEnum.PATHPATROL:
            throw new NotImplementedException();

        case MoveTypeEnum.PATHFLY:
            throw new NotImplementedException();

        default:
            throw new ArgumentOutOfRangeException();
        }
    }
コード例 #17
0
        internal static void ChangeWaitActionsToUseSpecialIdentifiers(List <ActionBase> actions)
        {
            for (int i = 0; i < actions.Count; i++)
            {
                ActionBase action = actions[i];
                if (action is WaitAction)
                {
                    WaitAction wAction = (WaitAction)action;
#pragma warning disable CS0612 // Type or member is obsolete
                    wAction.Amount = wAction.WaitAmount.ToString();
#pragma warning restore CS0612 // Type or member is obsolete
                }
            }
        }
コード例 #18
0
    //The main function! This EXACT coroutine will be executed, even across frames.
    //See GameAction.cs for more information on how this function should work!
    public override IEnumerator TakeAction()
    {
        while (true)
        {
            List <Monster> enemies = caller.view.visibleMonsters.FindAll(x => x.IsEnemy(caller));
            if (enemies.Count == 0)
            {
                Debug.Log("Monster is fleeing without seeing anyone. Resting instead.");
                //TODO: Use rest action instead!
                GameAction act = new WaitAction();
                act.Setup(caller);
                while (act.action.MoveNext())
                {
                    yield return(act.action.Current);
                }
                yield break;
            }

            float[,] fleeMap = Pathfinding.CreateFleeMap(enemies.Select(x => x.location).ToList());

            while (true)
            {
                Vector2Int next = nextSpot(caller.location, fleeMap);
                if (next == caller.location)
                {
                    Debug.Log($"{caller.name} has been cornered - stopping flee mode.");
                    //TODO: attack instead!
                    GameAction act = new WaitAction();
                    act.Setup(caller);
                    while (act.action.MoveNext())
                    {
                        yield return(act.action.Current);
                    }
                    yield break;
                }
                else
                {
                    MoveAction act = new MoveAction(next);
                    act.Setup(caller);
                    while (act.action.MoveNext())
                    {
                        yield return(act.action.Current);
                    }
                    yield return(GameAction.StateCheck);
                }
            }
        }
    }
コード例 #19
0
ファイル: Wait.cs プロジェクト: jaenudin86/dwarrowdelf
        ActionState ProcessAction(WaitAction action)
        {
            if (this.ActionTicksUsed == 1)
            {
                this.ActionTotalTicks = action.WaitTicks;
            }

            if (this.ActionTicksUsed < this.ActionTotalTicks)
            {
                return(ActionState.Ok);
            }
            else
            {
                return(ActionState.Done);
            }
        }
コード例 #20
0
        /// <summary>
        /// Polls quickly for short timeouts and less frequently for long operations.  This is ideal when waiting for long operations where 1 or more seconds do not matter.
        /// </summary>
        public static void WaitUntil(WaitAction action, string message, int timeOut = 10000, int tryTimes = DefaultTryTimes)
        {
            var waitingPeriod = timeOut / tryTimes;
            int triedTime     = 0;

            while (triedTime < tryTimes)
            {
                if (action())
                {
                    return;
                }
                Thread.Sleep(waitingPeriod);
                triedTime++;
            }
            throw new TimeoutException(message + " after waiting for " + timeOut + " millisecond");
        }
コード例 #21
0
        /// <summary>
        /// Poll actively for action/event, even for long runnnig events.
        /// </summary>
        public static void WaitForTimeoutOrActionComplete(WaitAction action, string message, TimeSpan timeOut, bool throwException = true)
        {
            DateTime now = DateTime.Now;

            while (DateTime.Now - now < timeOut)
            {
                if (action())
                {
                    return;
                }
                Thread.Sleep(50);
            }

            if (throwException)
            {
                throw new TimeoutException("Failed to " + message + " after waiting for " + timeOut);
            }
        }
コード例 #22
0
        protected override void OnProcess(Action.IAction action)
        {
            WaitAction waitAction = action as WaitAction;

            if (waitAction == null)
            {
                return;
            }

            LoggerManager.Debug(action.AutomationActionData);

            if (waitAction.Seconds > 0)
            {
                Sleep(waitAction.Seconds * 1000);
            }
            if (waitAction.Milliseconds > 0)
            {
                Sleep(waitAction.Milliseconds);
            }
        }
コード例 #23
0
        /// <summary>
        /// Waits for process completion.
        /// </summary>
        /// <param name="timeout">maximum time to wait.</param>
        /// <param name="waitCallBack">Callback while waiting for process exit (should not use up more then 1000ms).</param>
        /// <param name="throwEx">Throw exception if the process does not exit in time.</param>
        /// <returns></returns>
        public bool Wait(TimeSpan timeout, WaitAction waitCallBack, bool throwEx)
        {
            IStopWatch watch = DateTimeStopWatch.StartNew();
            bool       exit  = false;

            while (!exit && (watch.Elapsed < timeout))
            {
                if (Task.WaitAll(new Task[] { errorTask, outputTask }, 1))
                {
                    return(true);
                }

                waitCallBack?.Invoke(out exit);
            }
            if (throwEx)
            {
                throw new TimeoutException();
            }

            return(false);
        }
コード例 #24
0
        /// <summary>
        /// 需要配合waitAct中进行ExportInfoData()操作
        /// </summary>
        /// <param name="fileName"></param>
        /// <param name="waitAct">调用ExportInfoData()</param>
        public static void OpenSaveDialog(string fileName, WaitAction waitAct)
        {
            string         strFileName = string.Format("{0}{1:yyyyMMddHHmmss}", fileName, DateTime.Now);
            SaveFileDialog SaveFileDlg = new SaveFileDialog();

            SaveFileDlg.Filter   = "Excel文件(*.xls)|*.xls|Excel文件(*.xlsx)|*.xlsx";
            SaveFileDlg.FileName = strFileName;
            if (DialogResult.OK == SaveFileDlg.ShowDialog())
            {
                strFileName = SaveFileDlg.FileName;
                try
                {
                    waitAct(strFileName);
                }
                catch (Exception ex)
                {
                    //Log.Write.Error(ex.Message, ex);
                }
            }

            SaveFileDlg.Dispose();
        }
コード例 #25
0
ファイル: WaitActions.cs プロジェクト: blinds52/More
        // Returns true if this action has been reset for another time
        public Boolean Execute()
        {
            if (waitAction == null)
            {
                throw new InvalidOperationException("Someone called Execute on this wait action, but this WaitTimeAction was already executed and was not reset the last time it was executed");
            }

            Int64 savedStopwatchTicksToHandleAction = this.stopwatchTicksToHandleAction;

            waitAction(this);

            if (waitAction == null)
            {
                return(false);
            }
            if (savedStopwatchTicksToHandleAction == this.stopwatchTicksToHandleAction)
            {
                waitAction = null;
                return(false);
            }

            return(true);
        }
コード例 #26
0
        /// <summary>
        /// Cancels an order
        /// </summary>
        /// <param name="orderId">The id of the order to cancel</param>
        /// <returns></returns>
        public async Task <CallResult <bool> > CancelOrderAsync(long orderId)
        {
            if (!CheckConnection())
            {
                return(new CallResult <bool>(false, new WebError("Socket needs to be started before canceling an order")));
            }

            if (!authenticated)
            {
                return(new CallResult <bool>(false, new NoApiCredentialsError()));
            }

            log.Write(LogVerbosity.Info, "Going to cancel order " + orderId);
            var obj = new JObject {
                ["id"] = orderId
            };
            var wrapper = new JArray(0, "oc", null, obj);
            var data    = JsonConvert.SerializeObject(wrapper);

            bool done = false;
            await Task.Run(() =>
            {
                var waitAction = new WaitAction();
                pendingCancels.Add(orderId, waitAction);
                Send(data);
                done = waitAction.Wait(20000);
                pendingCancels.Remove(orderId);
            }).ConfigureAwait(false);

            if (done)
            {
                log.Write(LogVerbosity.Info, "Order canceled");
            }

            return(new CallResult <bool>(done, done ? null : new ServerError("No confirmation received for canceling order")));
        }
コード例 #27
0
        /// <summary>
        /// Reads the JSON representation of the object.
        /// </summary>
        /// <param name="reader">The <see cref="T:Newtonsoft.Json.JsonReader" /> to read from.</param>
        /// <param name="objectType">Type of the object.</param>
        /// <param name="existingValue">The existing value of object being read.</param>
        /// <param name="serializer">The calling serializer.</param>
        /// <returns>
        /// The object value.
        /// </returns>
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            ActionBase action = null;
            var condition = Condition.Equals;
            var actionName = string.Empty;
            var path = string.Empty;
            var value = string.Empty;
            var text = string.Empty;
            var expectedValue = string.Empty;
            var expectedText = string.Empty;
            var seconds = 0;

            while (reader.Read() && reader.TokenType != JsonToken.EndObject)
            {
                if (reader.TokenType == JsonToken.PropertyName)
                {
                    switch (reader.Value as string)
                    {
                        case "action":
                            actionName = reader.ReadAsString();
                            break;

                        case "path":
                            path = reader.ReadAsString();
                            break;

                        case "value":
                            value = reader.ReadAsString();
                            break;

                        case "text":
                            text = reader.ReadAsString();
                            break;

                        case "expectedValue":
                            expectedValue = reader.ReadAsString();
                            break;

                        case "expectedText":
                            expectedText = reader.ReadAsString();
                            break;

                        case "condition":
                            condition = (Condition)Enum.Parse(typeof (Condition), reader.ReadAsString(), true);
                            break;

                        case "seconds":
                            seconds = reader.ReadAsInt32() ?? 10;
                            break;
                    }
                }
            }

            switch (actionName)
            {
                case "click":
                    action = new ClickAction { Condition = condition, Path = path, Text = text, Value = value };
                    break;

                case "enterKey":
                    action = new EnterKeyAction { Condition = condition, Path = path, Text = text, Value = value };
                    break;

                case "navigateTo":
                    action = new NavigateToAction { Path = path };
                    break;

                case "selectItem":
                    action = new SelectItemAction { Condition = condition, Path = path, Text = text, Value = value };
                    break;

                case "setText":
                    action = new SetTextAction { Path = path, Value = value };
                    break;

                case "test":
                    action = new TestAction { Condition = condition, Path = path, ExpectedText = expectedText, ExpectedValue = expectedValue };
                    break;

                case "wait":
                    action = new WaitAction { Seconds = seconds };
                    break;
            }

            return action;
        }
コード例 #28
0
ファイル: WaitAssignment.cs プロジェクト: tomba/dwarrowdelf
 protected override GameAction PrepareNextActionOverride(out JobStatus progress)
 {
     var action = new WaitAction(m_turns);
     progress = JobStatus.Ok;
     return action;
 }
コード例 #29
0
 /// <summary>
 /// Executes the wait action
 /// </summary>
 /// <param name="action"></param>
 /// <param name="context"></param>
 public void Execute(WaitAction action, IExecutionContext context)
 {
     context.CancellationToken.WaitHandle.WaitOne(action.WaitSpan);
 }
コード例 #30
0
ファイル: AnimateWaitForm.cs プロジェクト: 521huaihuai/FishYu
        /// <summary>
        /// 注意鼠标会穿透,需要父窗体拦截点击事件
        /// <summary>
        public static void AnimatingWait(WaitAction waitAct, Control parent, GifType type = GifType.Default, bool isInMainThread = false, bool isSame = true, string content = "")
        {
            // 避免1秒内重复触发
            if (isSame && (DateTime.Now.Ticks - CurrentTimeTick) < 10000000)
            {
                return;
            }
            CurrentTimeTick = DateTime.Now.Ticks;
            WaitForm        form         = null;
            AnimateWaitForm animateImage = null;
            bool            isFinish     = false;

            //Gif动画展示
            Thread drawThread = new Thread(() =>
            {
                form = new WaitForm(parent, isInMainThread);
                Point drawPoint;
                Image _image;
                switch (type)
                {
                case GifType.Default:
                    _image = FishyuSelfControl.Properties.Resources.Spinner;
                    break;

                case GifType.Reload:
                    _image = FishyuSelfControl.Properties.Resources.Reload;
                    break;

                case GifType.LongSpin:
                    _image = FishyuSelfControl.Properties.Resources.LongSpin;
                    break;

                case GifType.OriginRotation:
                    _image = FishyuSelfControl.Properties.Resources.OriginRotation;
                    break;

                case GifType.OriginSizeRotation:
                    _image = FishyuSelfControl.Properties.Resources.OriginSizeRotation;
                    break;

                case GifType.StripLoading:
                    _image = FishyuSelfControl.Properties.Resources.StripLoading;
                    break;

                default:
                    _image = FishyuSelfControl.Properties.Resources.Reload;
                    break;
                }
                animateImage = new AnimateWaitForm(_image);

                drawPoint   = new Point((form.Width - _image.Width) / 2, (form.Height - _image.Height) / 2);
                form.Paint += ((obj, e) =>
                {
                    Graphics g = e.Graphics;
                    g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
                    g.PixelOffsetMode = PixelOffsetMode.Default; //高像素偏移质量
                    g.CompositingQuality = CompositingQuality.HighQuality;
                    //InterpolationMode不能使用High或者HighQualityBicubic,如果是灰色或者部分浅色的图像是会在边缘处出一白色透明的线
                    //用HighQualityBilinear却会使图片比其他两种模式模糊(需要肉眼仔细对比才可以看出)
                    g.InterpolationMode = InterpolationMode.Default;
                    g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
                    lock (animateImage.image)
                    {
                        try
                        {
                            g.DrawImage(animateImage.Image, drawPoint);
                        }
                        catch (Exception)
                        {
                        }
                        //g.DrawString()
                    }
                    //try
                    //{
                    //    g.DrawImage(animateImage.Image, drawPoint);
                    //}
                    //catch (Exception)
                    //{
                    //}
                });
                animateImage.Location       = form.Location;
                animateImage.Rect           = new Rectangle(animateImage.Location, new Size(_image.Width, _image.Height));
                animateImage.OnFrameChanged = ((image, evg) =>
                {
                    try
                    {
                        form.Invalidate(new Rectangle(drawPoint, new Size(_image.Width, _image.Height)));
                    }
                    catch (Exception)
                    {
                    }
                    //form.Invalidate();
                });

                //lock (_obj)
                //{

                //}
                if (form != null && !form.IsDisposed && !isFinish)
                {
                    animateImage.Play();
                    form.Focus();
                    form.ShowDialog();
                    //isOnShow = true;
                }
            });

            drawThread.IsBackground = true;
            drawThread.Start();


            //如果选择主线程阻塞
            if (isInMainThread)
            {
                waitAct();
                isFinish = true;
                CloseForm(animateImage, form);
            }
            else
            {
                Thread thread = new Thread(() =>
                {
                    waitAct();
                    isFinish = true;
                    CloseForm(animateImage, form);
                });
                thread.IsBackground = true;
                thread.Start();
            }
        }
コード例 #31
0
ファイル: AnimateWaitForm.cs プロジェクト: 521huaihuai/FishYu
 public static void AnimatingWait(WaitAction waitAct, Control parent, bool isInMainThread = false, bool isSame = true)
 {
     AnimatingWait(waitAct, parent, GifType.Default, isInMainThread, isSame, "");
 }
コード例 #32
0
ファイル: AnimateWaitForm.cs プロジェクト: 521huaihuai/FishYu
 public static void AnimatingWait(WaitAction waitAct, Control parent)
 {
     AnimatingWait(waitAct, parent, GifType.Default, false, true, "");
 }
コード例 #33
0
ファイル: AnimateWaitForm.cs プロジェクト: 521huaihuai/FishYu
 public static void AnimatingWait(WaitAction waitAct, bool isSame = true)
 {
     AnimatingWait(waitAct, null, false, isSame);
 }
コード例 #34
0
 private void Start()
 {
     _loadState  = LOADSTATE.CLEAR;
     _waitAction = WaitAction.Instance;
 }
コード例 #35
0
        protected override GameAction PrepareNextActionOverride(out JobStatus progress)
        {
            var random = this.Worker.World.Random;

            int rand = random.Next(100);

            GameAction action = null;

            Direction dir = m_dir;

            if (rand < 25)
            {
                dir = Direction.None;
            }
            else if (rand < 50)
            {
            }
            else if (rand < 75)
            {
                var v = dir.ToIntVector3();
                v = v.FastRotate(random.Next() % 2 == 0 ? 1 : -1);
                dir = v.ToDirection();
            }
            else
            {
                var v = dir.ToIntVector3();
                v = v.FastRotate(random.Next() % 2 == 0 ? 2 : -2);
                dir = v.ToDirection();
            }

            if (dir == Direction.None)
            {
                action = new WaitAction(random.Next(4) + 1);
            }
            else
            {
                var env = this.Worker.Environment;
                m_dir = dir;

                IntVector2 ov = dir.ToIntVector2();

                for (int i = 0; i < 7; ++i)
                {
                    var v = ov.FastRotate(((i + 1) >> 1) * (((i % 2) << 1) - 1));
                    var d = env.AdjustMoveDir(this.Worker.Location, v.ToDirection());

                    if (d != Direction.None)
                        action = new MoveAction(d);
                }

                if (action == null && this.Worker.CanMoveTo(Direction.Up))
                    action = new MoveAction(Direction.Up);

                if (action == null && this.Worker.CanMoveTo(Direction.Down))
                    action = new MoveAction(Direction.Down);

                if (action == null)
                    action = new WaitAction(random.Next(4) + 1);
            }

            progress = JobStatus.Ok;
            return action;
        }
コード例 #36
0
ファイル: MainWindow.xaml.cs プロジェクト: brentj73/Tellurium
        /// <summary>
        /// Changes the type of the action.
        /// </summary>
        private void ChangeActionType()
        {
            var selectedAction = PackageTreeView.SelectedItem as ActionBase;
            if (!_isChangingAction && selectedAction != null && ActionComboBox.SelectedItem != null)
            {
                var helper = new PackageHelper(_package);
                var action = ActionComboBox.SelectedItem as ComboBoxItem;

                if (action != null)
                {
                    switch (action.Tag.ToString())
                    {
                        case "Click":
                            if (selectedAction.GetType() != typeof(ClickAction))
                            {
                                var replacementAction = new ClickAction();
                                helper.ReplaceAction(selectedAction, replacementAction);
                                RefreshTreeView(replacementAction);
                            }
                            break;

                        case "EnterKey":
                            if (selectedAction.GetType() != typeof(EnterKeyAction))
                            {
                                var replacementAction = new EnterKeyAction();
                                helper.ReplaceAction(selectedAction, replacementAction);
                                RefreshTreeView(replacementAction);
                            }
                            break;

                        case "NavigateTo":
                            if (selectedAction.GetType() != typeof(NavigateToAction))
                            {
                                var replacementAction = new NavigateToAction();
                                helper.ReplaceAction(selectedAction, replacementAction);
                                RefreshTreeView(replacementAction);
                            }
                            break;

                        case "SelectItem":
                            if (selectedAction.GetType() != typeof(SelectItemAction))
                            {
                                var replacementAction = new SelectItemAction();
                                helper.ReplaceAction(selectedAction, replacementAction);
                                RefreshTreeView(replacementAction);
                            }
                            break;

                        case "SetText":
                            if (selectedAction.GetType() != typeof(SetTextAction))
                            {
                                var replacementAction = new SetTextAction();
                                helper.ReplaceAction(selectedAction, replacementAction);
                                RefreshTreeView(replacementAction);
                            }
                            break;

                        case "Test":
                            if (selectedAction.GetType() != typeof(TestAction))
                            {
                                var replacementAction = new TestAction();
                                helper.ReplaceAction(selectedAction, replacementAction);
                                RefreshTreeView(replacementAction);
                            }
                            break;

                        case "Wait":
                            if (selectedAction.GetType() != typeof(WaitAction))
                            {
                                var replacementAction = new WaitAction();
                                helper.ReplaceAction(selectedAction, replacementAction);
                                RefreshTreeView(replacementAction);
                            }
                            break;
                    }
                }
            }
        }