private void InitializeCardDisplays()
 {
     foreach (CardContainer card in CardManager.baseCardContainers)
     {
         CardDisplayController cardDisplay = Instantiate(cardDisplayControllerPrefab, cardsDisplayScrollRect.content);
         cardDisplay.Initialize(card.card, CollectionUtils.DuplicatesInDeck(CollectionManager.collection, card.card.index), AddCardToOpenDeck, ShowCardTradingUI);
         cardDisplays.Add(cardDisplay);
     }
     DisplayFullCollection();
 }
Exemplo n.º 2
0
    // Use this for initialization
    void Start()
    {
        // 获取位于网络管理器上的网络控制器
        //MainNetworkController = GameObject.Find("NetworkManager").GetComponent<NetworkController>();

        // 向网络管理器注册自己的数据包处理函数
        //MainNetworkController.ManagerRegistion("GameManager", MessageReceive);

        // 用于单场景开发时加载测试使用
        if (GameObject.Find("ClientPlayerManager") == null)
        {
            PlayerID           = 0;
            GameMapID          = "FreedomDay";
            FirstRoundPlayerID = 0;
        }
        else
        {
            MainClientPlayerController = GameObject.Find("ClientPlayerManager").GetComponent <ClientPlayerController>();
            PlayerID           = MainClientPlayerController.GetPlayerID();
            GameMapID          = MainClientPlayerController.GetGameMapID();
            FirstRoundPlayerID = MainClientPlayerController.GetFirstRoundPlayerID();
        }

        // 1. 生成所有游戏必要组件
        //===================================================================================================================
        MainLibraryManager = new LibraryManager(this);

        MainCardManager = new CardManager(this);

        MainResourceManager  = new ResourceManager(this);
        MainDiplomacyManager = new DiplomacyManager(this);
        MainRoundManager     = new RoundManager(this);


        MainEnvironmentManager = new EnvironmentManager(this);
        MainWorldManager       = new WorldManager(this);

        MainGameLoader = new GameLoader(this);

        MainInitialHandCardManager = new InitialHandCardManager(this);

        GameObject CardDisplayManagerPrefab = (GameObject)Resources.Load("Prefabs/Manager/GamePlay/CardDisplayManager");

        CardDisplayManager        = GameObject.Instantiate(CardDisplayManagerPrefab);
        CardDisplayManager.name   = "CardDisplayManager";
        MainCardDisplayController = CardDisplayManager.GetComponent <CardDisplayController>();
        MainCardDisplayController.Initialize(this);

        GameObject InputManagerPrefab = (GameObject)Resources.Load("Prefabs/Manager/GamePlay/InputManager");

        InputManager        = GameObject.Instantiate(InputManagerPrefab);
        InputManager.name   = "InputManager";
        MainInputController = InputManager.GetComponent <InputController>();
        MainInputController.SetCurrentPlayerID(PlayerID);
        MainInputController.Initialize(this);

        GameObject MessageManagerPrefab = (GameObject)Resources.Load("Prefabs/Manager/GamePlay/MassageManager");

        MessageManager        = GameObject.Instantiate(MessageManagerPrefab);
        MessageManager.name   = "MessageManager";
        MainMessageController = MessageManager.GetComponent <MessageController>();
        MainMessageController.Initialize(this);


        GameObject UIManagerPrefab = (GameObject)Resources.Load("Prefabs/Manager/GamePlay/UIManager");

        UIManager        = GameObject.Instantiate(UIManagerPrefab);
        UIManager.name   = "UIManager";
        MainUIController = UIManager.GetComponent <UIController>();
        MainUIController.Initialize(this);

        //2. 将游戏组件中的refernece建立
        //===================================================================================================================

        MainLibraryManager.EstablishReference();
        MainCardManager.EstablishReference();
        MainResourceManager.EstablishReference();
        MainDiplomacyManager.EstablishReference();
        MainRoundManager.EstablishReference();
        MainEnvironmentManager.EstablishReference();
        MainWorldManager.EstablishReference();
        MainGameLoader.EstablishReference();
        MainInitialHandCardManager.EstablishReference();

        MainCardDisplayController.EstablishReference();
        MainInputController.EstablishReference();
        MainMessageController.EstablishReference();
        MainUIController.EstablishReference();

        // 参数设置
        //===================================================================================================================

        MainRoundManager.SetCurrentRoundPlayerID(FirstRoundPlayerID);
        MainGameLoader.SetGameMapID(GameMapID);

        //===================================================================================================================
        MainLibraryManager.LoadGameDataFromXML();

        MainGameLoader.LoadGame();



        // 生成发送信息
        string SendMessage = "";

        // 通知网络管理器发送信息
        //CurrentMessageToBeSent = MainNetworkController.AddMessageInSendList(SendMessage);



        MainInitialHandCardManager.GenerateInitialHandCard(3);
    }