Example #1
0
File: Time.cs Project: 7474/SRC
        protected override ValueType InvokeInternal(SRC SRC, ValueType etype, string[] @params, int pcount, bool[] is_term, out string str_result, out double num_result)
        {
            str_result = "";
            num_result = 0d;

            num_result = GeneralLib.timeGetTime();
            if (etype == ValueType.StringType)
            {
                str_result = GeneralLib.FormatNum(num_result);
                return(ValueType.StringType);
            }
            else
            {
                return(ValueType.NumericType);
            }
        }
Example #2
0
File: WaitCmd.cs Project: 7474/SRC
        protected override int ExecInternal()
        {
            int wait_time, start_time, cur_time;

            switch (ArgNum)
            {
            case 2:
                switch (Strings.LCase(GetArg(2)) ?? "")
                {
                case "start":
                    Event.WaitStartTime = GeneralLib.timeGetTime();
                    Event.WaitTimeCount = 0;
                    break;

                case "reset":
                    Event.WaitStartTime = -1;
                    Event.WaitTimeCount = 0;
                    break;

                case "click":
                    //// 先行入力されていたクリックイベントを解消
                    GUI.Sleep(0, true);
                    Commands.WaitClickMode    = true;
                    GUI.IsFormClicked         = false;
                    Event.SelectedAlternative = "";

                    // ウィンドウが表示されていない場合は表示
                    if (!GUI.MainFormVisible)
                    {
                        GUI.MainFormShow();
                        GUI.UpdateScreen();
                    }

                    // クリックされるまで待つ
                    while (!GUI.IsFormClicked)
                    {
                        if (GUI.IsRButtonPressed(true))
                        {
                            GUI.MouseButton = GuiButton.Right;
                            break;
                        }

                        GUI.Sleep(25);
                    }

                    // マウスの左ボタンが押された場合はホットポイントの判定を行う
                    if (string.IsNullOrEmpty(Event.SelectedAlternative) && GUI.MouseButton == GuiButton.Left)
                    {
                        foreach (var hpoint in Event.HotPointList)
                        {
                            if (hpoint.Left <= GUI.MouseX && GUI.MouseX < (hpoint.Left + hpoint.Width) && hpoint.Top <= GUI.MouseY && GUI.MouseY < (hpoint.Top + hpoint.Height))
                            {
                                Event.SelectedAlternative = hpoint.Name;
                                break;
                            }
                        }
                    }

                    Commands.WaitClickMode = false;
                    GUI.IsFormClicked      = false;
                    break;

                default:
                    wait_time = (int)(100d * GetArgAsDouble(2));

                    // 待ち時間が切れるまで待機
                    if (wait_time < 1000)
                    {
                        if (!GUI.IsRButtonPressed(true))
                        {
                            GUI.Sleep(wait_time);
                        }
                    }
                    else
                    {
                        start_time = GeneralLib.timeGetTime();
                        while (start_time + wait_time > GeneralLib.timeGetTime())
                        {
                            // 右ボタンを押されていたら早送り
                            if (GUI.IsRButtonPressed(true))
                            {
                                break;
                            }

                            GUI.Sleep(25);
                        }
                    }

                    break;
                }

                break;

            case 3:
                // Wait Until ~
                wait_time           = (int)(100d * GetArgAsDouble(3));
                Event.WaitTimeCount = Event.WaitTimeCount + 1;
                if (Event.WaitStartTime == -1)
                {
                    // Wait Reset が実行されていた場合
                    Event.WaitStartTime = GeneralLib.timeGetTime();
                }
                else if (wait_time < 100)
                {
                    // アニメの1回目の表示は例外的に時間がかかってしまうことがある
                    // ので、超過時間を無視する
                    if (Event.WaitTimeCount == 1)
                    {
                        cur_time = GeneralLib.timeGetTime();
                        if (Event.WaitStartTime + wait_time > cur_time)
                        {
                            Event.WaitStartTime = cur_time;
                        }
                    }
                }

                while (Event.WaitStartTime + wait_time > GeneralLib.timeGetTime())
                {
                    if (GUI.IsRButtonPressed(true))
                    {
                        break;
                    }
                    GUI.Sleep(25);
                }

                break;

            default:
                throw new EventErrorException(this, "Waitコマンドの引数の数が違います");
            }

            return(EventData.NextID);
        }
Example #3
0
File: Main.gui.cs Project: 7474/SRC
        public void MoveUnitBitmap(Unit u, int x1, int y1, int x2, int y2, int wait_time0, int division)
        {
            int start_time = 0;
            int cur_time   = 0;
            int wait_time  = wait_time0 / division;

            SaveScreen();

            using (var unitImage = new Bitmap(MapCellPx, MapCellPx))
            {
                // ユニット画像を作成
                using (var g = Graphics.FromImage(unitImage))
                {
                    DrawUnit(g, Map.CellAtPoint(u.x, u.y), u, new Rectangle(0, 0, unitImage.Width, unitImage.Height));
                }

                // 移動の始点を設定
                var xx = GUI.MapToPixelX(x1);
                var yy = GUI.MapToPixelY(y1);
                var vx = 0;
                var vy = 0;

                // 背景上の画像をまず消去
                // (既に移動している場合を除く)
                if (ReferenceEquals(u, Map.MapDataForUnit[x1, y1]))
                {
                    EraseUnitBitmap(x1, y1, false);
                }

                // 最初の移動方向を設定
                if (Math.Abs((x2 - x1)) > Math.Abs((y2 - y1)))
                {
                    if (x2 > x1)
                    {
                        vx = 1;
                    }
                    else
                    {
                        vx = -1;
                    }

                    vy = 0;
                }
                else
                {
                    if (y2 > y1)
                    {
                        vy = 1;
                    }
                    else
                    {
                        vy = -1;
                    }

                    vx = 0;
                }

                if (wait_time > 0)
                {
                    start_time = GeneralLib.timeGetTime();
                }

                // 移動の描画
                var loopTo = (division * GeneralLib.MaxLng(Math.Abs((x2 - x1)), Math.Abs((y2 - y1))));
                for (var i = 1; i <= loopTo; i++)
                {
                    using (var g = Graphics.FromImage(MainDoubleBuffer))
                    {
                        // 画像を消去
                        var sourceRect = new Rectangle(xx, yy, MapCellPx, MapCellPx);
                        g.DrawImage(MainBuffer, sourceRect, sourceRect, GraphicsUnit.Pixel);

                        // 座標を移動
                        xx = (xx + MapCellPx * vx / division);
                        yy = (yy + MapCellPx * vy / division);

                        // 画像を描画
                        g.DrawImage(unitImage, xx, yy);
                    }
                    UpdataMain();

                    if (wait_time > 0)
                    {
                        do
                        {
                            Application.DoEvents();
                            cur_time = GeneralLib.timeGetTime();
                        }while (start_time + wait_time > cur_time);
                        start_time = cur_time;
                    }
                }

                // 2回目の移動方向を設定
                if (Math.Abs((x2 - x1)) > Math.Abs((y2 - y1)))
                {
                    if (y2 > y1)
                    {
                        vy = 1;
                    }
                    else
                    {
                        vy = -1;
                    }

                    vx = 0;
                }
                else
                {
                    if (x2 > x1)
                    {
                        vx = 1;
                    }
                    else
                    {
                        vx = -1;
                    }

                    vy = 0;
                }

                // 移動の描画
                var loopTo1 = (division * GeneralLib.MinLng(Math.Abs((x2 - x1)), Math.Abs((y2 - y1))));
                for (var i = 1; i <= loopTo1; i++)
                {
                    using (var g = Graphics.FromImage(MainDoubleBuffer))
                    {
                        // 画像を消去
                        var sourceRect = new Rectangle(xx, yy, MapCellPx, MapCellPx);
                        g.DrawImage(MainBuffer, sourceRect, sourceRect, GraphicsUnit.Pixel);

                        // 座標を移動
                        xx = (xx + MapCellPx * vx / division);
                        yy = (yy + MapCellPx * vy / division);

                        // 画像を描画
                        g.DrawImage(unitImage, xx, yy);
                    }

                    UpdataMain();

                    if (wait_time > 0)
                    {
                        do
                        {
                            Application.DoEvents();
                            cur_time = GeneralLib.timeGetTime();
                        }while (start_time + wait_time > cur_time);
                        start_time = cur_time;
                    }
                }
            }

            // 画面が書き換えられたことを記録
            GUI.ScreenIsSaved = false;
        }
Example #4
0
File: Main.gui.cs Project: 7474/SRC
        public void MoveUnitBitmap2(Unit u, int wait_time0, int division)
        {
            IList <int> move_route_x;
            IList <int> move_route_y;
            var         wait_time  = wait_time0 / division;
            var         start_time = 0;
            var         cur_time   = 0;

            SaveScreen();

            using (var unitImage = new Bitmap(MapCellPx, MapCellPx))
            {
                // ユニット画像を作成
                using (var g = Graphics.FromImage(unitImage))
                {
                    DrawUnit(g, Map.CellAtPoint(u.x, u.y), u, new Rectangle(0, 0, unitImage.Width, unitImage.Height));
                }

                // 移動経路を検索
                Map.SearchMoveRoute(u.x, u.y, out move_route_x, out move_route_y);
                if (wait_time > 0)
                {
                    start_time = GeneralLib.timeGetTime();
                }

                // 移動の始点
                var xx = GUI.MapToPixelX(move_route_x.Last());
                var yy = GUI.MapToPixelY(move_route_y.Last());
                for (var i = move_route_x.Count - 2; i >= 0; i--)
                {
                    var vx = GUI.MapToPixelX(move_route_x[i]) - xx;
                    var vy = GUI.MapToPixelY(move_route_y[i]) - yy;
                    // 移動の描画
                    for (var j = 0; j < division; j++)
                    {
                        using (var g = Graphics.FromImage(MainDoubleBuffer))
                        {
                            // 画像を消去
                            var sourceRect = new Rectangle(xx, yy, MapCellPx, MapCellPx);
                            g.DrawImage(MainBuffer, sourceRect, sourceRect, GraphicsUnit.Pixel);

                            // XXX 誤差大丈夫なんか?
                            // 座標を移動
                            xx = (xx + vx / division);
                            yy = (yy + vy / division);

                            // 画像を描画
                            g.DrawImage(unitImage, xx, yy);
                        }

                        UpdataMain();

                        if (wait_time > 0)
                        {
                            do
                            {
                                Application.DoEvents();
                                cur_time = GeneralLib.timeGetTime();
                            }while (start_time + wait_time > cur_time);
                            start_time = cur_time;
                        }
                    }
                }
            }

            // 画面が書き換えられたことを記録
            GUI.ScreenIsSaved = false;
        }