Beispiel #1
0
        /// <summary>
        /// ウィンドウサイズを画像の何倍かに合わせる
        /// </summary>
        void FitWindowSize()
        {
            // 0ならサイズ調整なし
            if (m_fitScale <= 0)
            {
                return;
            }

            // 最大化されているときは調整なし
            if (m_uniwin.IsMaximized)
            {
                return;
            }

            // 画像が読み込まれていなければ何もしない
            if (currentBitmap == null)
            {
                return;
            }

            var formerSize = m_uniwin.GetWindowSize();
            var pos        = m_uniwin.GetWindowPosition();

            int width  = (int)(currentBitmap.Width * m_fitScale);
            int height = (int)(currentBitmap.Height * m_fitScale);

            // Windows向けに、ウィンドウサイズ変更後左上が固定となるよう位置調整
            pos.y = pos.y + formerSize.y - height;

            //this.ClientSize = new Size(width, height);        // Formの機能でサイズ変更する場合

            m_uniwin.SetWindowSize(new UniWinCSharp.Vector2(width, height));
            m_uniwin.SetWindowPosition(pos);
        }
Beispiel #2
0
        /// <summary>
        /// 毎フレームの更新処理
        /// </summary>
        public void Update()
        {
            if (!isActive)
            {
                return;
            }

            // ジャンプ中または抑制中でなければ、ランダムでジャンプ開始
            if (!isMoving && !IsSuppressed)
            {
                var ms = stopwatch.ElapsedMilliseconds;
                if (nextJumpMilliSeconds <= ms)
                {
                    // 次回のジャンプを予定
                    nextJumpMilliSeconds = ms + random.Next(minWait, maxWait);

                    // ジャンプ開始
                    var size = uniwin.GetWindowSize();
                    height        = size.y * (0.1 + random.NextDouble() * 0.1); // ジャンプ高さを画像との比率で設定
                    pixelPerMeter = size.y * 1.0;

                    BeginJumping();
                }
            }

            UpdateJumping();
        }