Пример #1
0
    // Update is called once per frame
    void Update()
    {
        if (menuvisible | helpvisible | chooser.enabled)
        {
            return;
        }

        //処理開始
        interval += Time.deltaTime;
        if (interval > 0.1f & ready & !chooser.getEnabled())
        {
            //終了時刻よりあとの時刻か
            if (current.CompareTo(finish) > 0)
            {
                if (shadowrenderer.getMode() == UmbralShadowRenderer.RECORDMODE)
                {
                    String filename = EclipseCalendar.getDateString(start.Year, start.Month, start.Day);

                    currenteclipsedata.writeJSON(filename + ".json");
                    saveTexture(filename, result);
                    if (umbralshadow != null)
                    {
                        saveTexture(filename + "_umbra", umbralshadow);
                    }
                    return;

                    ready    = false;
                    interval = 0.0f;
                }
                else if (shadowrenderer.getMode() == UmbralShadowRenderer.PLAYMODE)
                {
                    current = new DateTime(start.Year, start.Month, start.Day, start.Hour, start.Minute, 0, DateTimeKind.Utc);
                }
            }

            clock.setTime(current);
            //影描画
            shadowrenderer.drawLines(current);

            //テクスチャに結果を描き込む
            if (shadowrenderer.getMode() == UmbralShadowRenderer.RECORDMODE)
            {
                writeResult(earthshadow, result);
            }

            //地球の昼夜を描く
            currenteclipsedata.getPositions(current, posdata);
            shadowrenderer.drawNightSide(posdata);

            earthshadow.Apply();
            //時間を一つ進める
            current = current.AddMinutes(1.0);

            interval = 0.0f;
        }

        if (Application.platform == RuntimePlatform.Android & !chooser.enabled & !helpvisible)
        {
            // エスケープキー取得
            if (Input.GetKeyDown(KeyCode.Escape))
            {
                // アプリケーション終了処理
                Application.Quit();
                return;
            }
        }
    }
Пример #2
0
    //
    void OnGUI()
    {
        if (!chooser.getEnabled() & !pointchooser.enabled)
        {
            switch (state)
            {
            case UNDER_HORIZON:
                GUI.DrawTexture(new Rect((Screen.width - images[ALERT_UNDERHORIZON].width) / 2, (Screen.height - images[ALERT_UNDERHORIZON].height) / 2,
                                         images[ALERT_UNDERHORIZON].width, images[ALERT_UNDERHORIZON].height), images[ALERT_UNDERHORIZON]);
                break;

            case INSIDE_SCREEN:
                GUI.DrawTexture(sunrect, images[SUNIMAGE]);
                //太陽の位置を表示する
                float left = 0.0f;
                float top  = 0.0f;

                if (sunrect.yMin < (Screen.height / 2))
                {
                    left = (Screen.width - images[SUNPOSITION].width) / 2;
                    top  = (Screen.height / 2) + ((Screen.height / 2) - images[SUNPOSITION].height) / 2;

                    GUI.DrawTexture(new Rect(left, top, images[SUNPOSITION].width, images[SUNPOSITION].height), images[SUNPOSITION]);
                }
                else if (sunrect.yMin >= (Screen.height / 2))
                {
                    left = (Screen.width - images[SUNPOSITION].width) / 2;
                    top  = ((Screen.height / 2) - images[SUNPOSITION].height) / 2;

                    GUI.DrawTexture(new Rect(left, top, images[SUNPOSITION].width, images[SUNPOSITION].height), images[SUNPOSITION]);
                }
                drawNumbers(left, top, direction_baseline, (float)sun_direction);
                drawNumbers(left, top, altitude_baseline, (float)sun_altitude);
                drawNumbers(left, top, longitude_baseline, longitude);
                drawNumbers(left, top, latitude_baseline, latitude);
                break;

            case OUTSIDE_SCREEN:
                blinkinterval += Time.deltaTime;
                if (blink)
                {
                    GUI.DrawTexture(new Rect((Screen.width - signboards[signboardnumber].width) / 2, (Screen.height - signboards[signboardnumber].height) / 2,
                                             signboards[signboardnumber].width, signboards[signboardnumber].height), signboards[signboardnumber]);
                    if (blinkinterval > 1.0f)
                    {
                        blink = false; blinkinterval = 0.0f;
                    }
                }
                else
                {
                    if (blinkinterval > 0.4f)
                    {
                        blink = true; blinkinterval = 0.0f;
                    }
                }
                break;

            case LOCATION_UNAVAILABLE:
                GUI.DrawTexture(new Rect((Screen.width - images[ALERT_LOCATION].width) / 2, (Screen.height - images[ALERT_LOCATION].height) / 2,
                                         images[ALERT_LOCATION].width, images[ALERT_LOCATION].height), images[ALERT_LOCATION]);
                break;
            }

            //メニューボタン表示
            if (GUI.Button(new Rect((Screen.width - images[MENUBUTTON].width) / 2, (Screen.height - images[MENUBUTTON].height - footmargin), images[MENUBUTTON].width, images[MENUBUTTON].height), images[MENUBUTTON]))
            {
#if UNITY_ANDROID
                menuvisible   = true;
                clock.enabled = false;

                // Javaのオブジェクトを作成
                AndroidJavaClass nativeDialog = new AndroidJavaClass("studio.beautifulworld.dialoglibrary.MenuDialog");

                // Context(Activity)オブジェクトを取得する
                AndroidJavaClass  unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
                AndroidJavaObject context     = unityPlayer.GetStatic <AndroidJavaObject>("currentActivity");

                // AndroidのUIスレッドで動かす
                context.Call("runOnUiThread", new AndroidJavaRunnable(() => {
                    // ダイアログ表示のstaticメソッドを呼び出す
                    nativeDialog.CallStatic(
                        "showButtons",
                        context,
                        "希望の動作を選んでください",
                        menuitems);
                }));
#endif
            }
        }
    }