Пример #1
0
        public MainView()
        {
            InitializeComponent();

            mainController = new MainController();
            this.SetController(mainController);

            mainModel = new MainModel();
            mainController.AddModel(mainModel);
            mainModel.AttachObserver(this);

            mapModel = new MapModel();
            mainController.AddModel(mapModel);
            mapModel.AttachObserver(this);

            MonsterPictureBoxInit();
            random = new Random();

            Notify(mapModel);
            Notify(mainModel);

            monsterCount = mapModel.MapList[mapModel.CurrentMap].monsterList.Count;
        }
Пример #2
0
 public void Notify(Model model)
 {
     if (model is MapModel)
     {
         MapModel map = (MapModel)model;
         OnBackgroundChanged();
         if (mainModel.GameStatus == "Main")
         {
             OnPlayerMain();
         }
         if (mainModel.GameStatus == "Battle")
         {
             object objMonsterBattle = Properties.Resources.ResourceManager.GetObject(mainModel.MonsterBattle.Name + "East");
             picMonsterBattlePosition.Image = (Image)objMonsterBattle;
         }
     }
     else if (model is MainModel)
     {
         OnGameStatusChanged();
         if (mainModel.GameStatus == "StartGame")
         {
             OnGameStart();
         }
         else if (mainModel.GameStatus == "Loading")
         {
             OnGameLoading();
         }
         else if (mainModel.GameStatus == "Main" && mainModel.BattleStatus == "Inactivity")
         {
             //if (mainModel.MenuStatusChanging) tmrMenu.Start();
             if (mainModel.CharacterSpawned)
             {
                 OnCharacterSpawn();
             }
             if (mainModel.PlayerCharacter.Moving)
             {
                 OnPlayerMoved();
             }
             OnBackgroundChanged();
             OnPlayerMain();
         }
         else if (mainModel.GameStatus == "Battle")
         {
             if (mainModel.BattleStatus == "Inactivity")
             {
                 OnPlayerBattle();
             }
             else if (mainModel.BattleStatus == "PlayerTurn" || mainModel.BattleStatus == "MonsterTurn")
             {
                 OnUpdateHealthBar();
             }
             else if (mainModel.BattleStatus == "EndToMain")
             {
                 mainModel.GameStatus   = "Main";
                 mainModel.BattleStatus = "Inactivity";
                 OnPlayerMain();
             }
         }
         else if (mainModel.GameStatus == "GameOver")
         {
             InvisibleAllObjects();
             pnlBG.BackgroundImage = Properties.Resources.GameOver;
         }
     }
 }