Example #1
0
 public void Init(int targetPlayerIndex, PlayerInfo targetPlayerInfo, PlayerManager targetPlayerManager, List <CardInfo> targetBasicCardInfo, PlayCardManager targetPlayCardManager)
 {
     playerIndex     = targetPlayerIndex;
     playerInfo      = targetPlayerInfo;
     playerManager   = targetPlayerManager;
     storeCardList   = targetBasicCardInfo;
     playCardManager = targetPlayCardManager;
 }
Example #2
0
    public void Init(PlayerInfo[] allPlayerArr, List <CardInfo> allStoreCardList, PlayCardManager playCardManager)
    {
        // PlayerInfoHolder
        GUIHelper.Instance.DestroyChildImmediatly <PlayerInfoHolder> (layout_PlayerInfoParent);

        // Player
        string playerHolderName = "PlayerHolder";

        if (transform.FindChild(playerHolderName))
        {
            DestroyImmediate(transform.FindChild(playerHolderName).gameObject);
        }

        Transform playerHolder = new GameObject(playerHolderName).transform;

        playerHolder.parent = transform;

        for (int i = 0; i < allPlayerArr.Length; i++)
        {
            //new card list;
            List <CardInfo> newCardInfoList = new List <CardInfo> ();
            newCardInfoList.AddRange(allStoreCardList);

            //new player
            GameObject newPlayerGObj = Instantiate(playerPrefab.gameObject) as GameObject;
            newPlayerGObj.name             = allPlayerArr [i].playerName;
            newPlayerGObj.transform.parent = playerHolder;

            //new playerInfoHolder
            GameObject newPlayerInfoHolderGObj = Instantiate(playerInfoHolderPrefab.gameObject) as GameObject;
            newPlayerInfoHolderGObj.name = allPlayerArr [i].playerName;
            newPlayerInfoHolderGObj.transform.SetParent(layout_PlayerInfoParent, false);
            PlayerInfoHolder newPlayerInfoHolder = newPlayerInfoHolderGObj.GetComponent <PlayerInfoHolder> ();
            newPlayerInfoHolder.Init(allPlayerArr [i]);

            //new train position
            TrainConnection newStartTrainConnection = GameManager.Instance.gamePlayManager.trainCommander.GetRandomPlayerStartTrainConnection();
            //new item
            ItemInfo   newItemInfo   = GameManager.Instance.gamePlayManager.BasicItemInfoArr [3];
            ItemHolder newItemHolder = Instantiate(itemHolderPrefab);
            newItemHolder.SetItemInfo(newItemInfo);

            PlayerManager newPlayerManager = newPlayerGObj.GetComponent <PlayerManager> ();
            newPlayerManager.Init(i, allPlayerArr [i], newPlayerInfoHolder, newCardInfoList, playCardManager
                                  , newStartTrainConnection, newItemHolder);

            allPlayerDict.Add(i, newPlayerManager);
        }
    }
    public void Init(int targetIndex, PlayerInfo targetPlayerInfo, PlayerInfoHolder targetPlayerInfoHolder
                     , List <CardInfo> targetCardList, PlayCardManager targetPlayCardManager, TrainConnection targetTrainConnection
                     , ItemHolder targetItemHolder)
    {
        playerIndex           = targetIndex;
        playerInfo            = targetPlayerInfo;
        playerRenderer        = playerTrans.GetComponent <SpriteRenderer> ();
        playerRenderer.sprite = Resources.Load <Sprite> (targetPlayerInfo.character.spriteUrl);
        text_PlayerName.text  = (playerIndex + 1) + ":" + playerInfo.playerName;

        healthController.Init(totalHealth, this, targetPlayerInfoHolder);
        cardController.Init(playerIndex, playerInfo, this, targetCardList, targetPlayCardManager);
        moveController.Init(this);
        moveController.Move(targetTrainConnection);
        playerTrans.position = moveController.standPos;

        itemController.Init(targetPlayerInfoHolder);
        itemController.StoreItem(targetItemHolder);
        bulletController.Init(maxBulletCount, targetPlayerInfoHolder);

        SetPlay(false);
    }