Esempio n. 1
0
    public void Init()
    {
        mArchievementSystem = new ArchievementSystem();
        mCampSystem         = new CampSystem();
        mCharacterSystem    = new CharacterSystem();
        mEnergySystem       = new EnergySystem();
        mGameEventSystem    = new GameEventSystem();
        mStageSystem        = new StageSystem();

        mCampInfoUI      = new CampInfoUI();
        mGamePauseUI     = new GamePauseUI();
        mGameStateInfoUI = new GameStateInfoUI();
        mSoldierInfoUI   = new SoldierInfoUI();

        mArchievementSystem.Init();
        mCampSystem.Init();
        mCharacterSystem.Init();
        mEnergySystem.Init();
        mGameEventSystem.Init();
        mStageSystem.Init();

        mCampInfoUI.Init();
        mGamePauseUI.Init();
        mGameStateInfoUI.Init();
        mSoldierInfoUI.Init();

        LoadMemento();
    }
Esempio n. 2
0
    //最好先Awake, 再Init. Awake中初始化数据, Init中再new对象之类的
    //不然部分new对象比较分散的,就不好给System初始化进行排序,有耦合。比如EventSubject
    public void Init()
    {
        m_AchievementSystem = new AchievementSystem();
        m_CampSystem        = new CampSystem();
        m_CharactorSystem   = new CharacterSystem();
        m_EnergySystem      = new EnergySystem();
        m_GameEventSystem   = new GameEventSystem();
        m_StageSystem       = new StageSystem();
        m_FileDataSystem    = new FileDataSystem();


        m_CampInfoUI      = new CampInfoUI();
        m_GamePauseUI     = new GamePauseUI();
        m_GameStateInfoUI = new GameStateInfoUI();
        m_SolderInfoUI    = new SoldierInfoUI();

        m_FileDataSystem.Init();
        m_AchievementSystem.Init();
        m_CampSystem.Init();
        m_CharactorSystem.Init();
        m_EnergySystem.Init();
        m_GameEventSystem.Init();
        m_StageSystem.Init();

        m_CampInfoUI.Init();
        m_GamePauseUI.Init();
        m_GameStateInfoUI.Init();
        m_SolderInfoUI.Init();
        LoadMemento();
    }
Esempio n. 3
0
    private SoldierInfoUI m_SoldierInfoUI;           //战士信息

    public void Init()
    {
        m_ArchievementSystem = new ArchievementSystem();
        m_CampSystem         = new CampSystem();
        m_CharacterSystem    = new CharacterSystem();
        m_EnergySystem       = new EnergySystem();
        m_GameEventSystem    = new GameEventSystem();
        m_StageSystem        = new StageSystem();

        m_CampInfoUI      = new CampInfoUI();
        m_GamePauseUI     = new GamePauseUI();
        m_GameStateInfoUI = new GameStateInfoUI();
        m_SoldierInfoUI   = new SoldierInfoUI();

        m_ArchievementSystem.Init();
        m_CampSystem.Init();
        m_CharacterSystem.Init();
        m_EnergySystem.Init();
        m_GameEventSystem.Init();
        m_StageSystem.Init();
        m_CampInfoUI.Init();
        m_GamePauseUI.Init();
        m_GameStateInfoUI.Init();
        m_SoldierInfoUI.Init();
    }
Esempio n. 4
0
    private void OnLevelEnd(bool has_won)
    {
        GameEventSystem.RaiseGameEvent(GAME_EVENT.GAME_PAUSED);
        int money_earned = 0;

        if (has_won)
        {
            Debug.Log("WON !");
            if (localLevelData != null)
            {
                money_earned = ScoreManager.GetTotalMoney(localLevelData.completed);
                LevelHelper.UpdateLevel(localLevelData.id, true, money_earned);
                LevelHelper.SaveLevelData();
                InventoryHelper.UpdateMoney(money_earned);
                InventoryHelper.SavePlayerData();
                PlayerPrefs.SetInt("last_level_id", localLevelData.id);
            }
            else
            {
                Debug.LogError("Cannot update level, levelData is null");
            }
        }
        else
        {
            playerGO.GetComponent <PlayerController>().OnPlayerDead();
            Debug.Log("LOST");
        }

        if (LevelUIManager.instance != null)
        {
            StartCoroutine(LevelUIManager.instance.ShowGameOverScreen(has_won, money_earned));
        }
    }
Esempio n. 5
0
 private void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
     }
 }
Esempio n. 6
0
 private void Start()
 {
     hasWon = false;
     if (quitButton != null)
     {
         quitButton.onClick.RemoveAllListeners();
         quitButton.onClick.AddListener(delegate() {
             Loader.Load(SceneName.Dashboard);
         });
     }
     else
     {
         Debug.LogError("Quit Button is null in " + transform.name);
     }
     if (replayButton != null)
     {
         replayButton.onClick.RemoveAllListeners();
         replayButton.onClick.AddListener(delegate() {
             GameEventSystem.RaiseGameEvent(GAME_EVENT.GAME_UNPAUSED);                 //because game is paused when player is died
             GameEventSystem.RaiseGameEvent(GAME_EVENT.LEVEL_START);
             gameObject.SetActive(false);
         });
     }
     else
     {
         Debug.LogError("Retry Button is null in " + transform.name);
     }
 }
    // 初始P-BaseDefense遊戲相關設定
    public void Initinal()
    {
        // 場景狀態控制
        m_bGameOver = false;
        // 遊戲系統
        m_GameEventSystem   = new GameEventSystem(this);        // 遊戲事件系統
        m_CampSystem        = new CampSystem(this);             // 兵營系統
        m_StageSystem       = new StageSystem(this);            // 關卡系統
        m_CharacterSystem   = new CharacterSystem(this);        // 角色管理系統
        m_ApSystem          = new APSystem(this);               // 行動力系統
        m_AchievementSystem = new AchievementSystem(this);      // 成就系統
        // 界面
        m_CampInfoUI      = new CampInfoUI(this);               // 兵營資訊
        m_SoldierInfoUI   = new SoldierInfoUI(this);            // Soldier資訊
        m_GameStateInfoUI = new GameStateInfoUI(this);          // 遊戲資料
        m_GamePauseUI     = new GamePauseUI(this);              // 遊戲暫停

        // 注入到其它系統
        EnemyAI.SetStageSystem(m_StageSystem);

        // 載入存檔
        LoadData();

        // 註冊遊戲事件系統
        ResigerGameEvent();
    }
 void PerformActionWithEventInfo(Event_Type eventType, EventInfo info)
 {
     GameEventSystem.DoEvent(
         eventType,
         info
         );
 }
Esempio n. 9
0
        public override void Update(GameTime time)
        {
            if (gameEventSystem == null)
            {
                gameEventSystem = GameEventSystem.GetFromServices(Services);
                gameEventSystem.RegisterListener(new TestJumpListener());
            }

            foreach (var kvp in ComponentDatas)
            {
                var movementComponent = kvp.Key;
                var data = kvp.Value;

                if (movementComponent.MoveDirection.HasValue)
                {
                    Move(movementComponent, data, movementComponent.MoveDirection.Value);
                    movementComponent.MoveDirection = null;
                }
                if (data.Character.IsGrounded)
                {
                    data.ModelEntityTransform.Entity.BroadcastEvent <IAnimationEvents>().SetGrounded(true);
                }
                if (movementComponent.ShouldJump)
                {
                    Jump(movementComponent, data);
                    movementComponent.ShouldJump = false;
                }
            }
        }
Esempio n. 10
0
 protected void OnDestroy()
 {
     if (Instance == this)
     {
         Instance = null;
     }
 }
Esempio n. 11
0
    public void Init()
    {
        systems = new List <IGameSystem>();

        achievementSystem = new AchievementSystem();
        campSystem        = new CampSystem();
        CharacterSystem   = new CharacterSystem();
        EnergySystem      = new EnergySystem();
        EventSystem       = new GameEventSystem();
        StageSystem       = new StageSystem();

        CampInfoUI      = new CampInfoUI();
        gamePauseUI     = new GamePauseUI();
        GameStateInfoUI = new GameStateInfoUI();
        soldierInfoUI   = new SoldierInfoUI();

        systems.Add(achievementSystem);
        systems.Add(campSystem);
        systems.Add(CharacterSystem);
        systems.Add(EnergySystem);
        systems.Add(EventSystem);
        systems.Add(StageSystem);

        systems.Add(CampInfoUI);
        systems.Add(gamePauseUI);
        systems.Add(GameStateInfoUI);
        systems.Add(soldierInfoUI);

        systems.ForEach(s => s.Init());


        var memento = CareTaker.RetrieveMemento(); //取回备忘录

        achievementSystem.RestoreMemento(memento); //根据备忘录,恢复成就系统
    }
	// 初始P-BaseDefense遊戲相關設定
	public void Initinal()
	{
		// 場景狀態控制
		m_bGameOver = false;
		// 遊戲系統
		m_GameEventSystem = new GameEventSystem(this);	// 遊戲事件系統
		m_CampSystem = new CampSystem(this);			// 兵營系統
		m_StageSystem = new StageSystem(this);			// 關卡系統
		m_CharacterSystem = new CharacterSystem(this); 	// 角色管理系統
		m_ApSystem = new APSystem(this);				// 行動力系統
		m_AchievementSystem = new AchievementSystem(this); // 成就系統
		// 界面
		m_CampInfoUI = new CampInfoUI(this); 			// 兵營資訊
		m_SoldierInfoUI = new SoldierInfoUI(this); 		// Soldier資訊									
		m_GameStateInfoUI = new GameStateInfoUI(this); 	// 遊戲資料
		m_GamePauseUI = new GamePauseUI (this);			// 遊戲暫停

		// 注入到其它系統
		EnemyAI.SetStageSystem( m_StageSystem );

		// 載入存檔
		LoadData();

		// 註冊遊戲事件系統
		ResigerGameEvent();
	}
Esempio n. 13
0
 // Update is called once per frame
 void Update()
 {
     // auto-start the game
     // TODO:
     if (GameData.singleton.currentStage == GameStage.GS_MAIN_MENU)
     {
         // testing save/load
         if (DebugOverrides.ShouldLoadSaveData && GameData.LoadGame())
         {
             Debug.Log("loaded game. resuming at " + GameData.singleton.currentStage.ToString());
             if (GameData.singleton.eventSaveData != null)
             {
                 GameEventSystem.Load(GameData.singleton.eventSaveData);
             }
             else
             {
                 Debug.LogWarning("eventSaveData was null");
             }
         }
         else
         {
             NewGame();
         }
         if (DebugOverrides.StartState.HasValue)
         {
             // TODO: figure out what functions need to be called here to make various stages somewhat functional
             // OR - just fast-forward and auto-OK until the desired state is reached
             GameData.singleton.currentStage = DebugOverrides.StartState.Value;
         }
     }
     else if (GameData.singleton.currentStage == GameStage.GS_SIMULATION && EventState.currentEvent == null)
     {
         GameData.singleton.quarterTimeElapsed += Time.deltaTime;
     }
 }
Esempio n. 14
0
    // 初始P-BaseDefense游戏相关设定
    public void Initinal()
    {
        // 场景状态控制
        m_bGameOver = false;
        // 游戏系统
        m_GameEventSystem   = new GameEventSystem(this);   // 游戏事件系统
        m_CampSystem        = new CampSystem(this);        // 兵营系统
        m_StageSystem       = new StageSystem(this);       // 关卡系统
        m_CharacterSystem   = new CharacterSystem(this);   // 角色管理系统
        m_ApSystem          = new APSystem(this);          // 行动力系统
        m_AchievementSystem = new AchievementSystem(this); // 成就系统
                                                           // 界面
        m_CampInfoUI      = new CampInfoUI(this);          // 兵营信息
        m_SoldierInfoUI   = new SoldierInfoUI(this);       // Soldier信息
        m_GameStateInfoUI = new GameStateInfoUI(this);     // 游戏资料
        m_GamePauseUI     = new GamePauseUI(this);         // 游戏暂停

        // 注入到其它系统
        EnemyAI.SetStageSystem(m_StageSystem);

        // 载入存档
        LoadData();

        // 注册游戏事件系统
        ResigerGameEvent();
    }
Esempio n. 15
0
    void Hotfix()
    {
        if (AppConfig.CheckVersionUpdate)
        {
#if UNITY_EDITOR
            CheckVersion();
#else
            if (Application.internetReachability == NetworkReachability.NotReachable)
            {
                //提示网络错误,检测网络连接是否正常
                // GameRoot.OpenCommonConfirm("网络连接失败", "网络连接失败,请检查网络连接是否正常?", () => { Application.Quit(); }, () => { Application.Quit(); });
                GameEventSystem.SendEvent(ShareEvent.OpenSelectMessageBox, "网络连接失败", "网络连接失败,请检查网络连接是否正常?",
                                          new CallbackSelect(NetworkAnomaly));
            }
            else
            {
                CheckVersion();
            }
#endif
        }
        else
        {
            StartOnFinish();
        }
    }
Esempio n. 16
0
    private System.Collections.IEnumerator cFightStart()
    {
        Singletones.hud.Status(FightData.fighter1._name + "\nVS\n " + FightData.fighter2._name, FightData.delay_before_first_round / 2);

        yield return(new WaitForSeconds(FightData.delay_before_first_round));

        GameEventSystem.TriggerEvent(GameEventSystem.EventID.RoundPreStart);
    }
Esempio n. 17
0
    //public float sensitivityX = 25F;
    //public float sensitivityY = 15F;

    //    public float minimumY = -60F;
    //public float maximumY = 60F;
    //float rotationY = 0F;

    // Use this for initialization
    void Start()
    {
        var go = GameObject.FindGameObjectWithTag("GameEventSystem");

        gameEventSystem = go.GetComponent <GameEventSystem>();

        gameEventSystem.Subscribe(this.gameObject, GameEventType.TurretOrientationChanged, OnTurretChange);
    }
Esempio n. 18
0
    private void Start()
    {
        GameEventSystem.StartListening(GameEventSystem.EventID.FightStart, Event_FightStart);
        GameEventSystem.StartListening(GameEventSystem.EventID.RoundPreStart, Event_RoundPreStart);
        GameEventSystem.StartListening(GameEventSystem.EventID.RoundPreStart, Event_RoundPreStart);
        GameEventSystem.StartListening(GameEventSystem.EventID.RoundEnd, Event_RoundEnd);
        GameEventSystem.StartListening(GameEventSystem.EventID.RoundResults, Event_RoundResults);

        FocusOnTwoFighters(true);
    }
Esempio n. 19
0
    private System.Collections.IEnumerator cRoundEnd()
    {
        string message = FightData.round_time >= FightData.round_duration ? "TIME IS UP" : "K.O.";

        Singletones.hud.Status(message, FightData.delay_after_round_end);

        yield return(new WaitForSeconds(FightData.delay_after_round_end));

        GameEventSystem.TriggerEvent(GameEventSystem.EventID.RoundResults);
    }
Esempio n. 20
0
    private IEnumerator ResetPlayer()
    {
        GameEventSystem.RaiseGameEvent(GAME_EVENT.GAME_PAUSED);
        playerGO.SetActive(false);
        playerGO.transform.position = partsOfLevel[currentPart].PlayerStartPosition.position;
        yield return(new WaitForSeconds(0.5f));

        playerGO.SetActive(true);
        GameEventSystem.RaiseGameEvent(GAME_EVENT.GAME_UNPAUSED);
    }
Esempio n. 21
0
    public override void PerformAction()
    {
        ColorChangeInfo valueChangeAction = new ColorChangeInfo();

        valueChangeAction.newColor = color;
        GameEventSystem.DoEvent(
            thisEvent_Type,
            valueChangeAction
            );
    }
Esempio n. 22
0
 public void Initinal()
 {
     isGameOver        = false;
     apSystem          = new APSystem(this);
     campSystem        = new CampSystem(this);
     stageSystem       = new StageSystem(this);
     gameEventSystem   = new GameEventSystem(this);
     characterSystem   = new CharacterSystem(this);
     achievementSystem = new AchievementSystem(this);
 }
 private void Awake()
 {
     #region Singleton
     if (instance != null)
     {
         return;
     }
     instance = this;
     #endregion
 }
Esempio n. 24
0
            public void PrepareGame()
            {
                _appEventSystem.LevelReady += StartGame;
                gameEventSystem             = new GameEventSystem();

                SimpleDependencyInjection.getInstance().Bind <GameEventSystem>(gameEventSystem);

                gameEventSystem.OnReachedGoalArea    += handleReachedGoal;
                gameEventSystem.OnDronesCoughtPlayer += handleDronesCaughtPlayer;
            }
    static void createOnJobRegisterCall(Job job)
    {
        JobRegisterInfo jobInfo = new JobRegisterInfo();

        jobInfo.job = job;
        GameEventSystem.DoEvent(
            Event_Type.JOB_REGISTERED_TO_PLAYER,
            jobInfo
            );
    }
Esempio n. 26
0
 public void OnUpdate()
 {
     ArchievementSystem.OnUpdate();
     CampSystem.OnUpdate();
     CharacterSystem.OnUpdate();
     EnergySystem.OnUpdate();
     GameEventSystem.OnUpdate();
     StageSystem.OnUpdate();
     UISystem.OnUpdate();
 }
Esempio n. 27
0
    //public PlayerStat stats;

    public override void PerformAction()
    {
        StatChangeInfo valueChangeAction = new StatChangeInfo();

        //valueChangeAction.playerStat = stats;
        GameEventSystem.DoEvent(
            thisEvent_Type,
            valueChangeAction
            );
    }
Esempio n. 28
0
    void Start()
    {
        var go = GameObject.FindGameObjectWithTag("GameEventSystem");

        gameEventSystem = go.GetComponent <GameEventSystem>();

        if (HighlightModel != null)
        {
            hightlightMeshes = HighlightModel.GetComponentsInChildren <MeshRenderer>();
        }
    }
Esempio n. 29
0
    //Delegatesta ja eventistä. Näillä kukkaro saa lähetettyä rahanmuutoksesta viestin kaikille onincreasen tilanneille
    //classeille viestin siitä, että rahatilanne on muuttunut, delegaten ja eventin avulla näitä tilaajia ei tarvitse
    //erikseen unityn editorissä määritellä, eli toisinsanoen pelaajan kukkaron ei tarvitse tietää, kenelle tätä viestiä lähetetään.

    static PlayerEconomy()
    {
        GameEventSystem.RegisterListener(Event_Type.FLOAT_CHANGE, SetMoney);
        GameEventSystem.RegisterListener(Event_Type.JOB_REGISTERED_TO_PLAYER, RegisterAnIncomeSourceFromJob);
        GameEventSystem.RegisterListener(Event_Type.EXTRA_INCOME, registerExtraIncome);

        TaxationSystem.getIncomeafterMandatoryPayments(getAllIncomeSourceGrossTotals(12));

        DateTimeSystem.OnMonthChange += PayFromIncomeSources;
        DateTimeSystem.OnMonthChange += deductExpenses;
    }
    public override void PerformAction()
    {
        WelfareApplyFormInfo form = new WelfareApplyFormInfo();

        form.typeofWelfare = typeofWelfare;
        thisEvent_Type     = Event_Type.PLAYER_WANTS_WELFARE;
        GameEventSystem.DoEvent(
            thisEvent_Type,
            form
            );
    }
    // 遊戲事件
    void UnitTest_GameEvent()
    {
        GameEventSystem EventSys = new GameEventSystem(null);

        // 註冊
        EventSys.RegisterObserver(ENUM_GameEvent.EnemyKilled, new EnemyKilledObserverUI(null));
        EventSys.RegisterObserver(ENUM_GameEvent.EnemyKilled, new EnemyKilledObserverAchievement(null));

        // 通知
        EventSys.NotifySubject(ENUM_GameEvent.EnemyKilled, null);
    }
	// 遊戲事件
	void UnitTest_GameEvent()
	{
		GameEventSystem EventSys = new GameEventSystem( null );

		// 註冊
		EventSys.RegisterObserver( ENUM_GameEvent.EnemyKilled, new EnemyKilledObserverUI(null));
		EventSys.RegisterObserver( ENUM_GameEvent.EnemyKilled, new EnemyKilledObserverAchievement(null));

		// 通知
		EventSys.NotifySubject ( ENUM_GameEvent.EnemyKilled, null );
	}