Esempio n. 1
0
    public void Awake()
    {
        Instance = this;

        DataTableManager = new DataTableManager();
        DataTableManager.LoadTownTable(TestData.TownInfoTable);
        DataTableManager.FleetInfo = TestData.Fleet;
        DataTableManager.LoadCommodityTable(TestData.CommodityTable);
        var save = TestData.Saves;

        EntityList = new List<Entity>();

        //创建城镇
        GameDataManager = new GameObject("GameDataManager").AddComponent<GameDataManager>();
        GameDataManager.TownList = new List<Town>();
        foreach (var townInfo in DataTableManager.TownTable.Values)
        {
            var town = new Town();
            town.Info = townInfo;
            var townSave = save.TownList.Find(x => x.ID == townInfo.ID);
            if (null != townSave)
            {
                town.LoadSave(townSave);
            }
            GameDataManager.TownList.Add(town);
            EntityList.Add(town);
            town.Reset();
        }

        Map.Setup(GameDataManager.TownList);

        //创建舰队
        var fleet = new Fleet();
        fleet.Info = DataTableManager.FleetInfo;
        fleet.Position = new Vector2(0, 0);
        fleet.Actor = Map.transform.Find("Fleet").GetComponent<FleetActor>();
        fleet.Actor.Model = fleet;
        fleet.Reset();
        EntityList.Add(fleet);
        FocusedFleet = fleet;

        WorldTime = 0;
        TickCountDownRemaining = 0;
        //CurrentTownSettleSeconds = -1;
    }
Esempio n. 2
0
    /// <summary>
    /// 用來作初始化
    /// </summary>
    void Start()
    {
        _gameGUIPanel = GameGUIPanel.Instance;

        _gameState = GameNone.Instance;
        _dataTableManager = new DataTableManager();
        _sceneManager = new SceneManager();
        _playerInput = PlayerInput.Instance;
        _cameraManager = new CameraManager();
        _gameEventManager = new GameEventManager();
        _gameEventState = new GameEventState();

        _npcUnitManager = NPCUnitManager.Instance;

        // 進入遊戲前需處理好的class,加載位置可能要換
        _startDependencies.Add(_dataTableManager);
    }
Esempio n. 3
0
 void OnDestroy()
 {
     _gameGUIPanel = null;
     _gameState = null;
     _dataTableManager = null;
     _sceneManager = null;
     if (_playerInput != null)
     {
         Destroy(_playerInput);
         _playerInput = null;
     }
     _cameraManager = null;
     _gameEventManager = null;
     _gameEventState = null;
     if (_npcUnitManager != null)
     {
         Destroy(_npcUnitManager);
         _npcUnitManager = null;
     }
     _instance = null;
 }