Пример #1
0
        /*-------------------------------------------------------------------------
         * キャプチャ
         * ---------------------------------------------------------------------------*/
        private void do_capture()
        {
            // 前回のキャプチャからの経過時間を得る
            int sectiontime = m_capture_timer.GetSectionTimeMilliseconds();

            if (sectiontime < m_capture_interval)
            {
                // キャプチャ間隔ではない
                return;
            }
            // 間隔測定リセット
            m_capture_timer.StartSection();

            // 情報更新
            update_myship_data(sectiontime, get_myship_data());
        }
Пример #2
0
        /*-------------------------------------------------------------------------
         * 到達予想位置
         * 到達予想位置を描画したときtrueを返す
         * ---------------------------------------------------------------------------*/
        private bool draw_expect_pos(Vector2 pos, float speed)
        {
            // 表示する必要があるかチェック
            if (!is_draw_expect_pos)
            {
                return(false);
            }
            // 最低速度
            if (speed_calculator.MapToKnotSpeed(speed) < STEP_POSITION_SPEED_MIN)
            {
                return(false);
            }

            // 経過時間
            int sectiontime = m_expect_pos_timer.GetSectionTimeMilliseconds();

            // 表示用の速度を求める
            speed  = transform_speed(speed, m_lib.loop_image);
            speed *= 1f / 60;                                           // 1秒での距離に変換
            speed *= 1f / 1000;                                         // sectiontime に合わせる(1sec=1000)
            speed *= sectiontime;                                       // 経過時間分距離を進める
            pos   += m_expect_vector * speed;                           // 移動ベクトルを更新

            // 予想位置描画
            m_lib.device.sprites.AddDrawSpritesNC(new Vector3(pos.X, pos.Y, 0.3f), m_lib.icons.GetIcon(icons.icon_index.myship));
            return(true);
        }
Пример #3
0
        /*-------------------------------------------------------------------------
         * 도달예상위치
         * 도달예상위치를 그리기시작하면 true를 반환
         * ---------------------------------------------------------------------------*/
        private bool draw_expect_pos(Vector2 pos, float speed)
        {
            // 표시する必要があるかチェック
            if (!is_draw_expect_pos)
            {
                return(false);
            }
            // 최저속도
            if (speed_calculator.MapToKnotSpeed(speed) < STEP_POSITION_SPEED_MIN)
            {
                return(false);
            }

            // 경과시간
            int sectiontime = m_expect_pos_timer.GetSectionTimeMilliseconds();

            // 표시용の속도を求める
            speed  = transform_speed(speed, m_lib.loop_image);
            speed *= 1f / 60;                           // 1초동안의 거리를 변환
            speed *= 1f / 1000;                         // sectiontime에 합침(1sec=1000)
            speed *= sectiontime;                       // 경과시간분 거리를 진행
            pos   += m_expect_vector * speed;           // 이동벡터를 업데이트

            // 예상위치그리기
            m_lib.device.sprites.AddDrawSpritesNC(new Vector3(pos.X, pos.Y, 0.3f), m_lib.icons.GetIcon(icons.icon_index.myship));
            return(true);
        }
Пример #4
0
        /*-------------------------------------------------------------------------
         * 캡처
         * ---------------------------------------------------------------------------*/
        private void do_capture()
        {
            // 前회の캡처からの경과시간を得る
            int sectiontime = m_capture_timer.GetSectionTimeMilliseconds();

            if (sectiontime < m_capture_interval)
            {
                // 캡처간격ではない
                return;
            }
            // 간격測定리셋
            m_capture_timer.StartSection();

            // 정보업데이트
            update_myship_data(sectiontime, get_myship_data());
        }
Пример #5
0
        /*-------------------------------------------------------------------------
         * 自分の船の情報更新
         * クライアントから受信した情報か自ら得た情報かは考慮されない
         * ---------------------------------------------------------------------------*/
        private void update_myship_data(int sectiontime, gvo_analized_data data)
        {
            //
            if (data == null)
            {
                return;
            }

            // 航路記録なしならなにもしない
            if (!m_lib.setting.save_searoutes)
            {
                // 位置と角度は初期化する
                m_pos           = new Point(-1, -1);
                m_is_in_the_sea = false;
                // 到達予想をリセット
                reset_expect();
                return;
            }

            // 経過時間だけ追加
            m_db.SpeedCalculator.AddIntervalOnly(sectiontime);

            // 造船開始と終了
            // 同時にフラグが立った場合は終了を優先する
            if (data.is_start_build_ship)
            {
                m_db.BuildShipCounter.StartBuildShip(data.build_ship_name);
            }
            if (data.is_finish_build_ship)
            {
                m_db.BuildShipCounter.FinishBuildShip();
            }

            // 日付キャプチャ成功なら利息からの日数を更新する
            if (data.capture_days_success)
            {
                // 利息からの日数を更新する
                m_db.InterestDays.Update(data.days, data.interest);
                // 造船日数を更新する
                m_db.BuildShipCounter.Update(data.days);
            }
            else
            {
                if (m_expect_delay_timer.GetSectionTimeMilliseconds() > OUT_OF_SEA_TIME_OUT)
                {
                    // 海上ではない
                    m_is_in_the_sea = false;
                    // 到達予想をリセット
                    reset_expect();
                }
                // 日付キャプチャ失敗ならそれ以外の解析を行わない
                return;
            }

            // キャプチャが成功したかチェック
            if (!data.capture_success)
            {
                // 日付のみキャプチャ成功
                m_is_draw_expect_pos = true;                            // 到達予想位置を描画する必要あり
                // ディレイタイマリセット
                m_expect_delay_timer.StartSection();
                return;
            }

            // 自分の船の位置
            m_pos            = new Point(data.pos_x, data.pos_y);
            m_angle          = data.angle;
            m_is_in_the_sea  = true;                            // 海上
            m_capture_sucess = true;                            // キャプチャ成功

            // 測量位置を追加する
            // 位置によっては追加されない
            m_db.SeaRoute.AddPoint(m_pos,
                                   data.days,
                                   gvo_chat.ToIndex(data.accident));

            // 速度算出
            // 更新間隔はすでに設定済み
            m_db.SpeedCalculator.Add(m_pos, 0);

            // キャプチャ時は描画をスキップしない
            m_lib.device.SetMustDrawFlag();

            // 到達位置予想用角度の更新
            m_expect_vector = transform.ToVector2(gvo_capture.AngleToVector(m_angle));
            // タイマリセット
            m_expect_pos_timer.StartSection();
            m_expect_delay_timer.StartSection();
            m_is_draw_expect_pos = false;                       // 解析できてるので予想位置を描画する必要がない
        }
Пример #6
0
        /*-------------------------------------------------------------------------
         * イメージとの合成
         * Begin()を読んだ直후に呼ぶこと
         * must_margeがtrueのとき必ず合成する
         * デバイスロスト時は必ず合成する
         * 合成しないときは handler にnullを지정できる
         *
         * デバイスロスト時の処理を含むため, 必ず呼び出す必要がある
         * ---------------------------------------------------------------------------*/
        public void MergeImage(DrawHandler handler, bool must_merge)
        {
            if (!m_device_lost && !must_merge)
            {
                return;
            }

            DateTimer d = new DateTimer();

            // 텍스쳐업데이트
            foreach (TextureUnit tex in m_textures)
            {
                tex.RefreshTexture();
            }
            // 合成대상がなければ返る
            if (handler == null)
            {
                m_device_lost = false;
                // 合成に掛かった시간
                MargeImageMS = d.GetSectionTimeMilliseconds();
                return;
            }

            // 合成
            // 렌더링 타겟を지정
            Surface depth      = m_device.device.DepthStencilSurface;
            Surface backbuffer = m_device.device.GetBackBuffer(0, 0, BackBufferType.Mono);

            m_device.device.DepthStencilSurface = null;                  // zバッファ없음

            try
            {
                foreach (TextureUnit tex in m_textures)
                {
                    // 렌더링 타겟を설정

                    if (tex.Texture == null)
                    {
                        continue;                                                 // 텍스쳐が作れていない
                    }
                    //					Surface	a	= ((Texture)null).GetSurfaceLevel(0);
                    m_device.device.SetRenderTarget(0, tex.Texture.GetSurfaceLevel(0));
                    m_device.UpdateClientSize();

                    // 그리기위치と스케일を退避
                    PushDrawParams();
                    m_offset = -tex.Offset;
                    SetScale(1, new Point(0, 0), false);

                    // 렌더링
                    handler(m_offset, this);

                    PopDrawParams();
                }
            }
            catch
            {
                // 保険
                PopDrawParams();
            }

            // 렌더링 타겟を元に戻す
            m_device.device.DepthStencilSurface = depth;
            m_device.device.SetRenderTarget(0, backbuffer);
            m_device.UpdateClientSize();

            backbuffer.Dispose();
            depth.Dispose();

            m_device_lost = false;
            // 合成に掛かった시간
            MargeImageMS = d.GetSectionTimeMilliseconds();
        }
Пример #7
0
        /*-------------------------------------------------------------------------
         * 본인の배の정보업데이트
         * クライアントから受信した정보か自ら得た정보かは考慮されない
         * ---------------------------------------------------------------------------*/
        private void update_myship_data(int sectiontime, gvo_analized_data data)
        {
            //
            if (data == null)
            {
                return;
            }

            // 항로기록없음ならなにもしない
            if (!m_lib.setting.save_searoutes)
            {
                // 위치と각도は初期化する
                m_pos           = new Point(-1, -1);
                m_is_in_the_sea = false;
                // 도달예상を리셋
                reset_expect();
                return;
            }

            // 경과시간だけ추가
            m_db.SpeedCalculator.AddIntervalOnly(sectiontime);

            // 조선개시と종료
            // 同時に플래그が立った場合は종료を優先する
            if (data.is_start_build_ship)
            {
                m_db.BuildShipCounter.StartBuildShip(data.build_ship_name);
            }
            if (data.is_finish_build_ship)
            {
                m_db.BuildShipCounter.FinishBuildShip();
            }

            // 일付캡처成功なら이자からの일수を업데이트する
            if (data.capture_days_success)
            {
                // 이자からの일수を업데이트する
                m_db.InterestDays.Update(data.days, data.interest);
                // 조선일수を업데이트する
                m_db.BuildShipCounter.Update(data.days);
            }
            else
            {
                if (m_expect_delay_timer.GetSectionTimeMilliseconds() > OUT_OF_SEA_TIME_OUT)
                {
                    // 해상ではない
                    m_is_in_the_sea = false;
                    // 도달예상を리셋
                    reset_expect();
                }
                // 일付캡처실패ならそれ以외の분석を行わない
                return;
            }

            // 캡처が成功したかチェック
            if (!data.capture_success)
            {
                // 일付のみ캡처成功
                m_is_draw_expect_pos = true;                            // 도달예상위치を그리기する必要あり
                // ディレイタイマ리셋
                m_expect_delay_timer.StartSection();
                return;
            }

            // 본인の배の위치
            m_pos            = new Point(data.pos_x, data.pos_y);
            m_angle          = data.angle;
            m_is_in_the_sea  = true;             // 해상
            m_capture_sucess = true;             // 캡처成功

            // 측량위치を추가する
            // 위치によっては추가されない
            m_db.SeaRoute.AddPoint(m_pos,
                                   data.days,
                                   gvo_chat.ToIndex(data.accident));

            // 속도算出
            // 업데이트간격はすでに설정済み
            m_db.SpeedCalculator.Add(m_pos, 0);

            // 캡처時は그리기を스킵しない
            m_lib.device.SetMustDrawFlag();

            // 도달위치예상용각도の업데이트
            m_expect_vector = transform.ToVector2(gvo_capture.AngleToVector(m_angle));
            // タイマ리셋
            m_expect_pos_timer.StartSection();
            m_expect_delay_timer.StartSection();
            m_is_draw_expect_pos = false;               // 분석できてるので예상위치を그리기する必要がない
        }