コード例 #1
0
ファイル: GameManager.cs プロジェクト: nullsuke/Pacman
    //ステージ開始時の初期化。
    private void SetGame()
    {
        //パックマンの作成。
        pacman = Instantiate(pacmanPrefab, maze.transform);
        //パックマンの初期位置は必ず整数でないと移動中に引っかかる。
        pacman.Initialize(maze.PacmanStartPosition);
        //パックマン死亡時のイベントを登録。
        pacman.OnDead += (s, e) => CheckLives();

        //ゴーストの作成。
        PlaceGhost();
        //エサの作成。
        PlaceDot();
        //パワーエサの作成。
        PlacePowerCokie();
        //残機の更新。
        UpdateLives();

        fruitsCreator = GetComponent <FruitsCreator>();
        fruitsCreator.Initialize();

        scareEndTime = 0;
        eatenGhost   = 0;
        eatenDot     = 0;
    }
コード例 #2
0
        static void Main(string[] args)
        {
            ProductCreator prodCreator = new VegetablesCreator();
            Inventory      inventory   = new Inventory();

            inventory.Add(prodCreator.Create("Carrot", 12.5, 2, 2));
            inventory.Add(prodCreator.Create("Potato", 6.1, 4.1, 4.0));
            prodCreator = new FruitsCreator();
            inventory.Add(prodCreator.Create("Apple", 20, 12, 12.1));
            inventory.Add(prodCreator.Create("Pineapple", 70, 4.0, 4.0));
            prodCreator = new MeatCreator();
            inventory.Add(prodCreator.Create("Biff", 173, 2.0, 2.0));

            inventory.Display(DisplayProduct);
        }