Beispiel #1
0
        // ----------------------------------------------------
        #region // Public Methods

        public EnemySpawner(ECSManager ecsManager, EnemySettings enemySettings, Vector2[] spawnPoints)
        {
            this._ecsBoostrap   = ecsManager;
            this._enemySettings = enemySettings;
            this._spawnPoints   = spawnPoints;
            this._maxEnemyID    = Enum.GetNames(typeof(EnemyID)).Length;
        }
        float _survivalTime = 0f; // 生存時間

        #endregion                // Private Fields


        // ----------------------------------------------------
        #region // Unity Events

        /// <summary>
        /// MonoBehaviour.Start
        /// </summary>
        void Start()
        {
            this._gameStatus = new GameStatus(this._addScore);

            // ECSの初期化
            this._ecsManager = new ECSManager(this._lookSettings, this._collider2DSettings, this._enemySettings, this._gameStatus);

            // UniRx.AsyncとUnity.Entitiesの和解
            var playerLoop = ScriptBehaviourUpdateOrder.CurrentPlayerLoop;

            PlayerLoopHelper.Initialize(ref playerLoop);

#if ENABLE_DEBUG
            // FPSCounterの起動
            this._fpsCounter = new FPSCounter();
            Observable.EveryUpdate().Subscribe(_ => this._fpsCounter.UpdateInternal()).AddTo(this.gameObject);
#endif

            // プレイヤーのインスタンス化 & 初期化
            var obj = Instantiate <GameObject>(this._playerPrefab);
            this._player = obj.GetComponent <Player>();
            this._player.Initialize(this._ecsManager);
            this._player.OnDestroy.Subscribe(_ => this.OnGameOver()).AddTo(this.gameObject);

            // 敵生成ロジックのインスタンス化
            this._enemySpawner = new EnemySpawner(this._ecsManager, this._enemySettings, this._spawnPoints);

            // UI Event Settings
            this._titleUI.OnGameStartClick.Subscribe(_ => this.OnGameStart()).AddTo(this.gameObject);
            this._titleUI.OnRankingCkick.Subscribe(_ => this.Ranking()).AddTo(this.gameObject);
            this._resultUI.OnRetryClick.Subscribe(_ => this.OnGameStart()).AddTo(this.gameObject);
            this._resultUI.OnRankingCkick.Subscribe(_ => this.Ranking()).AddTo(this.gameObject);
            this._resultUI.OnTweetCkick.Subscribe(_ => this.Tweet()).AddTo(this.gameObject);

            // Audio & Particle Settings
            this._ecsManager.OnDestroyEnemy.Subscribe(pos =>
            {
                // Audio
                this.PlaySE(SE_ID.EnemyDestroy);
                // TODO: Add Particle
            }).AddTo(this.gameObject);

            this._player.OnDestroy.Subscribe(pos =>
            {
                // Audio
                this.PlaySE(SE_ID.PlayerDestroy);
                // TODO: Add Particle
            }).AddTo(this.gameObject);

            this._player.OnShot.Subscribe(pos =>
            {
                // Audio
                this.PlaySE(SE_ID.PlayerShot);
                // TODO: Add Particle
            }).AddTo(this.gameObject);

            // タイトルの表示
            this._titleUI.Show();
        }
Beispiel #3
0
        // ----------------------------------------------------
        #region // Public Methods

        public void Initialize(ECSManager ecsManager)
        {
            // 初回1回のみ呼ばれる想定。
            // インスタンスの生成などを行う。
            this._mainCamera     = Camera.main;
            this._arrowTrs       = this._arrowMesh.transform;
            this._mainCameraPosZ = this._mainCamera.transform.localPosition.z;
            this._ecsManager     = ecsManager;

            this._barrierMaterialAlphaID = Shader.PropertyToID(Constants.BarrierMaterialAlpha);

            this._barrierMaterialInstance = new Material(this._barrierMaterial);
            this._barrierMesh.material    = this._barrierMaterialInstance;
            this._playerStatus            = new PlayerStatus(this._playerSettings.Param);

            // 終わったら非表示にしておく
            this.Hide();
        }