コード例 #1
0
        public GameController(MainWindow window)
        {
            unitFactory = UnitFactory.Instance;
            behaviourFactory = BehaviourFactory.Instance;
            moveContainer = new MoveContainer();
            drawContainer = new DrawContainer();
            units = new ArrayList();
            
            this.window = window;

            timer = new Timer();

            dispatcher = Dispatcher.CurrentDispatcher;

            currentLevel = new BaseLevelState(this); //maak level 1 aan
            currentLevel.NextLevel();

            Crow.AddUnitToFactory();
            Duck.AddUnitToFactory();

            Unit unit1 = unitFactory.CreateUnit("Duck", moveContainer, drawContainer, behaviourFactory, window);
            units.Add(unit1);
            //Thread t = new Thread(new ThreadStart(gameLoop));
            //t.Start();

            Unit unit2 = unitFactory.CreateUnit("Crow", moveContainer, drawContainer, behaviourFactory, window);
            units.Add(unit2);

            t2 = new Thread(new ThreadStart(gameLoop));
            t2.Start();
        }
コード例 #2
0
        public Unit CreateUnit(string name, MoveContainer mc, DrawContainer dc, BehaviourFactory bf, MainWindow window)
        {
            if (unitMap.ContainsKey(name))
            {
                return unitMap[name].CreateInstance(mc, dc, bf, window);
            }

            throw new Exception("Unit with the name "+ name +" Not Found");
        }
コード例 #3
0
ファイル: Duck.cs プロジェクト: JoepvdBroek/DP2_Duckhunt
        public Duck(MoveContainer mc, DrawContainer dc, BehaviourFactory bf, MainWindow window)
            : base(mc, dc, bf, window)
        {
            //rnd = new Random();
            size = 40;
            x = 0;
            y = rnd.Next(26, 300);
            color = Brushes.PowderBlue;
            velocity = 1.0F;
            heading = 1.5F;

            InitUnit();
        }
コード例 #4
0
ファイル: Unit.cs プロジェクト: JoepvdBroek/DP2_Duckhunt
        public Unit(MoveContainer mc, DrawContainer dc, BehaviourFactory bf, MainWindow window)
        {
            moveContainer = mc;
            drawContainer = dc;
            behaviourFactory = bf;
            this.window = window;

            moveBehaviour = behaviourFactory.CreateMoveBehaviour(this, "flying");
            drawBehaviour = behaviourFactory.CreateDrawBehaviour(this, "flying");
            moveContainer.Add(moveBehaviour);
            drawContainer.Add(drawBehaviour);

            this.window = window;
            dispatcher = Dispatcher.CurrentDispatcher;
        }
コード例 #5
0
ファイル: Crow.cs プロジェクト: JoepvdBroek/DP2_Duckhunt
        public Crow(MoveContainer mc, DrawContainer dc, BehaviourFactory bf, MainWindow window)
            : base(mc, dc, bf, window)
        {
            //rnd = new Random();
            size = 40;
            x = 0;
            y = rnd.Next(26, 300);
            color = Brushes.Black;
            velocity = 1.0F;
            heading = 1.5F;

            this.window = window;
            dispatcher = Dispatcher.CurrentDispatcher;

            InitUnit();
        }
コード例 #6
0
ファイル: Duck.cs プロジェクト: JoepvdBroek/DP2_Duckhunt
 public override Unit CreateInstance(MoveContainer mc, DrawContainer dc, BehaviourFactory bf, MainWindow window)
 {
     return new Duck(mc, dc, bf, window);
 }
コード例 #7
0
ファイル: Unit.cs プロジェクト: JoepvdBroek/DP2_Duckhunt
 public abstract Unit CreateInstance(MoveContainer mc, DrawContainer dc, BehaviourFactory bf, MainWindow window);