Beispiel #1
0
    public void TaskAppear()
    {
        float elapsedTime = Time.deltaTime;

        if (IsTimeOver())
        {
            // 経過時間オーバーなので処理しない
            return;
        }
        // 総合経過時間を加算
        totalTime += elapsedTime;
        //Debug.Log(string.Format("time={0}", totalTime));

        if (IsDataEnd())
        {
            // データ実行終了 or データがない
            return;
        }

        bool isContinue = true;

        while (isContinue)
        {
            if (currentIndex >= maxCount)
            {
                // データが終端まで実行している
                return;
            }
            StgStageJsonEnemyLaunchData launchData = stgStageJsonEnemyLaunchDatas.Get(currentIndex);
            if (launchData.time <= (int)totalTime)
            {
                // 敵の生成
                {
                    GameObject enemy = enemyFactory.Create(StgEnemyConstant.GetStringToType(launchData.enemy_type), launchData.enemyItemDropDatas);

                    //Instantiate(enemy, new Vector3(launchData.x, launchData.y, launchData.z), Quaternion.identity);

                    // ドロップアイテム設定
                    NormalEnemy enemyBase = enemy.GetComponent <NormalEnemy>();
                    enemyBase.SetPosition(new Vector2(launchData.x, launchData.y));
                    StgItemMultiDropper dropper = new StgItemMultiDropper();
                    for (int i = 0; i < launchData.enemyItemDropDatas.GetCount(); ++i)
                    {
                        StgStageJsonEnemyItemDropData dropData = launchData.enemyItemDropDatas.Get(i);
                        dropper.SetParameter(dropData.Offset, dropData.Type);
                    }
                    dropper.Print();
                    enemyBase.SetItemDropper(dropper);
                }
                ++currentIndex;
            }
            else
            {
                // 処理すべきtimeのデータがない
                return;
            }
        }
    }
Beispiel #2
0
    // Start is called before the first frame update
    void Start()
    {
        {
            // 敵出現システムの初期化
            if (enemyRandomPopper == null)
            {
                // プレイヤーのGameObjectを取得
                GameObject player = GameObject.Find("Player");
                MhCommon.Assert(player != null, "GameMainSceneTask::Start() player null");

                enemyRandomPopper = this.gameObject.AddComponent <StgEnemyRandomPopper>() as StgEnemyRandomPopper;
                MhCommon.Assert(enemyRandomPopper != null, "GameMainSceneTask::Start() StgEnemyRandomPopper AddComponent failure");
                enemyRandomPopper.SetPlayer(player);
                MhCommon.Print("random popper created");
            }
            // ステージデータ読み込み
            {
                stgEnemyLoadResourceStageJson = new StgEnemyLoadResourceStageJson();
                stgEnemyLoadResourceStageJson.Initialize(SceneShare.Instance.GetGameResourcePathData().Get(GameResourcePathDefine.Type.kStageData01));
                //stgEnemyLoadResourceStageJson.SetResourcePath("");
                //stgEnemyLoadResourceStageJson.Load();
                stgEnemyJsonDataPopper = this.gameObject.AddComponent <StgEnemyJsonDataPopper>() as StgEnemyJsonDataPopper;
                MhCommon.Assert(stgEnemyJsonDataPopper != null, "GameMainSceneTask::Start() StgEnemyJsonDataPopper AddComponent failure");
                // プレイヤーのGameObjectを取得
                GameObject player = GameObject.Find("Player");
                MhCommon.Assert(player != null, "GameMainSceneTask::Start() player null");
                stgEnemyJsonDataPopper.SetPlayer(player);
                stgEnemyJsonDataPopper.SetJsonEnemyLaunchDatas(stgEnemyLoadResourceStageJson.Get());
            }
            {
                // パワーアップアイテムとスコアアイテムのドロップ
                StgItemMultiDropper dropper = new StgItemMultiDropper();
                dropper.SetParameter(new Vector3(0, 0, 0), StgItemConstant.Type.kPowerup);
                dropper.SetParameter(new Vector3(0.5f, 0, 0), StgItemConstant.Type.kScoreup);
                dropper.Print();
                dropper.Drop();
            }
        }
    }
Beispiel #3
0
    public override GameObject Create(StgEnemyConstant.Type type, StgStageJsonEnemyItemDropDatas itemDropDatas)
    {
        NormalEnemy normalEnemy = null;

        if (type == StgEnemyConstant.Type.kEnemyNormal)
        {
            GameObject enemy = (GameObject)Resources.Load(SceneShare.Instance.GetGameResourcePathData().Get(GameResourcePathDefine.Type.kNormalEnemyPrefab));
            MhCommon.Assert(enemy != null, "StgEnemyFactory::Create() kEnemyNormal null");
            enemy = Object.Instantiate(enemy);

            normalEnemy = enemy.GetComponent <NormalEnemy>();
            StgItemMultiDropper dropper = new StgItemMultiDropper();
            for (int i = 0; i < itemDropDatas.GetCount(); ++i)
            {
                StgStageJsonEnemyItemDropData dropData = itemDropDatas.Get(i);
                dropper.SetParameter(dropData.Offset, dropData.Type);
            }
            dropper.Print();
            normalEnemy.SetItemDropper(dropper);

            /*
             *              NormalEnemy enemyBase = enemy.GetComponent<NormalEnemy>();
             *              StgItemMultiDropper dropper = new StgItemMultiDropper();
             *              for (int i = 0; i < launchData.enemyItemDropDatas.GetCount(); ++i) {
             *                      StgStageJsonEnemyItemDropData dropData = launchData.enemyItemDropDatas.Get(i);
             *                      dropper.SetParameter(dropData.Offset, dropData.Type);
             *              }
             *              dropper.Print();
             *              enemyBase.SetItemDropper(dropper);
             *
             */

            return(enemy);
        }
        else if (type == StgEnemyConstant.Type.kStraightMoveEnemy)
        {
            GameObject enemy = (GameObject)Resources.Load(SceneShare.Instance.GetGameResourcePathData().Get(GameResourcePathDefine.Type.kStraightMoveEnemyPrefab));
            MhCommon.Assert(enemy != null, "StgEnemyFactory::Create() kNormalEnemyPrefab null");
            enemy = Object.Instantiate(enemy);
            return(enemy);
        }
        else
        {
            MhCommon.Assert(false, "StgEnemyFactory::Create() StgEnemyConstant.Type invalid type=" + type);
            return(null);
        }
    }