コード例 #1
0
ファイル: GameController.cs プロジェクト: KittyMac/LD32
    public void Start()
    {
        GameIsOver = false;

        roadGenerator = new RoadGenerator();

        roadGenerator.GenerateRoadMap(LevelNumber);

        CreateTiledRoad(roadGenerator);

        CreateScenary();

        CreatePlayerObject();


        NumberOfKetchupUses = 10;

        NumberOfCollectedTurnips = 0;
        for (int i = 0; i < NumberOfTurnipsThisLevel; i++)
        {
            AddTurnip();
        }

        NotificationCenter.addObserver(this, "SpawnAllEnemies", null, (args, name) => {
            if (enemies.Count == 0)
            {
                for (int i = 0; i < (LevelNumber); i++)
                {
                    AddEnemyOfType1();
                }

                EndIntro();
            }
        });

        NotificationCenter.addObserver(this, "UnconventionalWeaponActivate", null, (args, name) => {
            if (NumberOfKetchupUses > 0)
            {
                GameObject localKetchupAnim = GameObject.Instantiate(KetchupAnim, player.transform.position, Quaternion.Euler(new Vector3(0, 45, 0))) as GameObject;
                localKetchupAnim.SetActive(true);
                LeanTween.delayedCall(1.0f, () => {
                    GameObject.DestroyImmediate(localKetchupAnim);
                });

                Vector3 pos = player.transform.position;
                pos.y       = 2;
                GameObject localKetchupSpill = GameObject.Instantiate(KetchupSpill, pos, Quaternion.Euler(new Vector3(90, 320, 0))) as GameObject;
                localKetchupSpill.SetActive(true);
                ketchupSpills.Add(localKetchupSpill);

                NumberOfKetchupUses--;
            }
        });

        AnimateIntro();
    }