5/24記録

今日やったこと

ワーキングメモリーレーニン

鬼ネズミ、鬼計算、鬼耳算をやりました。

Lv11を中心に120問やりました。

力学

C#の勉強

読書

英語

  • 音読英単語入門編 Unit 1 ~ 4 6周目

ゲーム開発

ResultUIを管理する

ResultUIの表示、非表示をGameStateを参照して切り替える為のクラスであるResultUIControllerクラスを作成しました。

これまでと同様にZenjectとUniRxを使用しています。

using UnityEngine;
using Zenject;
using UniRx;

public class ResultUIController : MonoBehaviour
{
    [Inject] private GameStateManager gameStateManager;

    // Start is called before the first frame update
    void Start()
    {
        DisplayResultUI();

        HideResultUI();
    }

    private void DisplayResultUI()
    {
        gameStateManager
            .CurrentGameState
            .Where(state => state == GameState.Result)
            .Subscribe(_ => this.gameObject.SetActive(true))
            .AddTo(this);
    }

    private void HideResultUI()
    {
        gameStateManager
            .CurrentGameState
            .Where(state => state != GameState.Result)
            .Subscribe(_ => this.gameObject.SetActive(false))
            .AddTo(this);
    }

}

リトライボタンの作成

ResultUIの子オブジェクトとしてRetryButtonを作成しました。

f:id:alberto_hojo:20190524144923p:plain:w300

このボタンを押すとStart状態になるようにします。

この「Start状態に移る」を行うために、InitializeManagerというpureなクラスを作成しました。

using Zenject;

public class InitializeManager
{
    [Inject] private GameStateManager gameStateManager;

    public void GoToStartState()
    {
        gameStateManager.SetGameState(GameState.Start);
    }

    public void GoToHomeState()
    {
        gameStateManager.SetGameState(GameState.Home);
    }

}

これに伴ってGameSceneInstallerにも変更を加えました。

using UnityEngine;
using Zenject;

public class GameSceneInstaller : MonoInstaller
{
    public override void InstallBindings()
    {
        Container
            .Bind<GameStateManager>()
            .AsSingle();

        Container
            .Bind<VictoryStateManager>()
            .AsSingle();

        Container
            .Bind<InitializeManager>()
            .AsSingle();
    }
}

次にRetryButtonを押した時に行う処理を担当するRetryButtonクラスを作成しました。

using UnityEngine;
using Zenject;
using UnityEngine.UI;

public class RetryButton : MonoBehaviour
{
    [Inject] private GameStateManager gameStateManager;

    [Inject] private InitializeManager initializeManager;

    private Button button;

    // Start is called before the first frame update
    void Start()
    {
        button = this.GetComponent<Button>();

        button.onClick.AddListener(PushRetryButton);
    }

    private void PushRetryButton()
    {
        initializeManager.GoToStartState();
    }

}

スマートフォンに対応させる

これまではPCのキーボード入力により操作を行っていましたが、スマートフォンからも行えるようにInputFromSmartphoneクラスを作成しました。

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class InputFromSmartphone : MonoBehaviour, IInput
{
    //しきい値を設定
    private float threshold = 0.1f;

    public Vector3 MoveVector
    {
        get
        {
            if (Input.acceleration.x > this.threshold)
            {
                return new Vector3(1, 0, 0);
            }
            else if (Input.acceleration.x < -this.threshold)
            {
                return new Vector3(-1, 0, 0);
            }
            else
            {
                return new Vector3(0, 0, 0);
            }
        }
    }
}

クラス図はこんな感じになりました。

f:id:alberto_hojo:20190524234415p:plain

だいたい基本的な機能は実装できたかなと思うので、これでとりあえず完成ということにします。

機械学習始めました

面白いゲームを作るためには「頼もしい仲間」と「手強い敵」が不可欠なので、それらのAIを作れるようになるために機械学習の勉強を始めました。

というところで本日は終了です。

測定結果

JINS MEME ESという最新の学術研究の成果を元に人間の心理状態を測定できるウェアラブルバイスを使って本日の僕の集中状態を測定した結果は以下のようになりました。

f:id:alberto_hojo:20190525001124p:plain:w200

作業時間 9時間26分 + 英語シャドーイング1時間

集中時間 3時間14分

集中率 34%