コード例 #1
0
        private static void Main(string[] args)
        {
            Console.WriteLine("Welcome to Observer Pattern");

            Console.WriteLine("Creating Publisher");
            var wavePublisher = new WavePublisher();

            Console.WriteLine("Adding Monsters");

            var MonsterA  = new MonsterA(wavePublisher, "MonsterA");
            var MonsterA2 = new MonsterA(wavePublisher, "MonsterA2");
            var MonsterB  = new MonsterB(wavePublisher, "MonsterB");
            var MonsterC  = new MonsterC(wavePublisher, "MonsterC");

            for (int i = 0; i < 5; i++)
            {
                Console.WriteLine("Incrementing Wave");
                wavePublisher.NextWave();
                Thread.Sleep(3000);
            }
        }
コード例 #2
0
ファイル: Game.cs プロジェクト: fdtemp/GameTask
    void Start()
    {
        PlayerPrefab      = Resources.Load <GameObject>("Player");
        MonsterPrefab     = Resources.Load <GameObject>("Monster");
        HealthBoardPrefab = Resources.Load <GameObject>("HealthBoard");
        LaserPrefab       = Resources.Load <GameObject>("Laser");
        Camera            = GameObject.Find("Camera");

        Seed        = new System.Random();
        Monsters    = new List <Monster>();
        MonsterPool = new Dictionary <string, ObjectPool <Monster> >();
        MonsterA.Init();
        MonsterB.Init();
        Player    = new Player();
        LaserPool = new ObjectPool <GameObject>(
            15,
            delegate() {
            return(GameObject.Instantiate <GameObject>(LaserPrefab));
        },
            delegate(GameObject l) {
            l.SetActive(true);
            return(true);
        },
            delegate(GameObject l) {
            l.SetActive(false);
            return(true);
        },
            delegate(GameObject l) {
            GameObject.Destroy(l);
            return(true);
        });

        Player.EXP       = 0;
        LastGenerateTime = Time.time - MonsterGenerateInterval;
        Player.SetPosition(new Vector3(0, 0));
        Stopped = false;
    }