Example #1
0
    public BoardPlayer CreatePlayer(LudoType playerType)
    {
        BoardPlayer player = new BoardPlayer(playerType);

        boardPlayers.Add(new BoardPlayerInfo(player, playerType, 0)); // TODO update starting tile use tile manager
        return(player);
    }
Example #2
0
    // Use this for initialization
    public List <Card> SpawnPlayerCards(BoardPlayer me, BoardPlayer enemy, CardDefinitionHolder[] cardHolders)
    {
        List <Card> cards = new List <Card>();

        for (int i = 0; i < cardHolders.Length; i++)
        {
            CardDefinition cardDefinition = cardHolders[i].CardDefinition;

            Card card = Summon(cardDefinition);
            card.owner       = me;
            card.enemy       = enemy;
            card.gameManager = GameManager;
            card.slotNumber  = i;

            card.SpawnPointImage = playerSpawnPoints[i].GetComponent <Image>();

            GameObject cardGO = card.gameObject;

            cardGO.transform.SetParent(playerSpawnPoints[i].transform, false);
            cardGO.transform.localPosition = playerOffset;
            cards.Add(card);
        }

        return(cards);
    }
Example #3
0
    public void NewTurn()
    {
        turnNumber++;
        Debug.Log("Starting new turn:" + turnNumber);

        player.NewTurn(turnNumber);
        enemy.NewTurn(turnNumber);

        if (initiationList.Count == 0)
        {
            NextRound();
        }

        Debug.Log("Initiation order: " + InitiationListToString());

        activeCard = initiationList[0];
        activeCard.isActiveCard = true;
        initiationList.Remove(activeCard);

        PlayersTurn = activeCard.owner == player;
        activeCard.HighlightActiveCard();

        Debug.Log("Active card: " + activeCard.definition.Name);

        BoardPlayer activePlayer = activeCard.owner;

        if (activePlayer == player)
        {
            EnablePlayerInteractions();
        }

        activePlayer.Play(activeCard);

        Debug.Log("Player on turn: " + activePlayer.name);
    }
Example #4
0
    public void CreateLocalPlayer(LudoType playerType, string playerName, BoardPlayer boardPlayer, BoardPlayerUI boardPlayerUI)
    {
        var player = new LocalPlayer(playerType, playerName, boardPlayer, boardPlayerUI);

        rulesManager.AddPlayer(player);
        players.Add(player);
    }
Example #5
0
    private List <Card> SpawnEnemyCards(BoardPlayer me, BoardPlayer enemy, CardDefinitionHolder[] cardHoldersToSpawn, GameObject[] spawnPoints, Vector3 offset)
    {
        List <Card> cards = new List <Card>();

        for (int i = 0; i < cardHoldersToSpawn.Length; i++)
        {
            CardDefinition cardDefinition = cardHoldersToSpawn[i].CardDefinition;
            int            index          = cardHoldersToSpawn[i].Position;

            Card card = Summon(cardDefinition);
            card.owner       = me;
            card.enemy       = enemy;
            card.gameManager = GameManager;
            card.slotNumber  = index;

            GameObject cardGO = card.gameObject;

            card.SpawnPointImage = spawnPoints[index].GetComponent <Image>();

            cardGO.transform.SetParent(spawnPoints[index].transform, false);
            cardGO.transform.localPosition = offset;
            cards.Add(card);
        }

        return(cards);
    }
Example #6
0
        /// <summary>
        /// For the given player, decide which cards in the hand should be shown, and where
        /// </summary>
        /// <param name="player"></param>
        /// <param name="hand"></param>
        private void PlaceCards(BoardPlayer player, List <Card> hand)
        {
            int i           = war.GameTable.Player1Cards.Count - 1;
            int placedCards = 0;

            // show as many as 5 cards that the user should have on the table
            while (placedCards < CardsOnTablePerPlayer && i >= 0)
            {
                // show most recent in the front
                switch (placedCards)
                {
                case 0:
                    ShowCard((player == BoardPlayer.WarriorWendy ? imgPlayer1Card : imgPlayer2Card), hand[i]);
                    break;

                case 1:
                    ShowCard((player == BoardPlayer.WarriorWendy ? imgPlayer1CardB : imgPlayer2CardB), hand[i]);
                    break;

                case 2:
                    ShowCard((player == BoardPlayer.WarriorWendy ? imgPlayer1CardC : imgPlayer2CardC), hand[i]);
                    break;

                case 3:
                    ShowCard((player == BoardPlayer.WarriorWendy ? imgPlayer1CardD : imgPlayer2CardD), hand[i]);
                    break;

                case 4:
                    ShowCard((player == BoardPlayer.WarriorWendy ? imgPlayer1CardE : imgPlayer2CardE), hand[i]);
                    break;
                }
                placedCards++;
                i--;
            }
        }
Example #7
0
    private void CreateLocalPlayer(LudoType playerType, string playerName)
    {
        BoardPlayerUI boardPlayerUI = boardUI.GetPlayer(playerType);
        BoardPlayer   boardPlayer   = board.CreatePlayer(playerType);

        boardPlayerUI.SetUITileManager(uiTileManager);
        playerManager.CreateLocalPlayer(playerType, playerName, boardPlayer, boardPlayerUI);
    }
 public Player(BoardPlayer PlayerType)
 {
     _playerType = PlayerType;
     _score = 0;
     _lives = 0;
     _freeLives = 0;
     _gameOver = true;
 }
Example #9
0
 public LocalPlayer(LudoType playerType, string playerName, BoardPlayer boardPlayer, BoardPlayerUI boardPlayerUI)
 {
     playerBoardType    = playerType;
     this.playerName    = playerName;
     playerOriginalType = playerType;
     this.boardPlayer   = boardPlayer;
     this.boardPlayerUI = boardPlayerUI;
     InitPawnData();
 }
Example #10
0
 public void NewTurn(bool _new, BoardPlayer player)
 {
     if (_new == true)
     {
         playerTurn.SetActive(true);
         time = playerTurnTextDelay;
     }
     else
     {
         playerTurn.SetActive(false);
     }
 }
Example #11
0
 public void getPlayers() //Loads all players and gets our player instance.
 {
     players.Clear();
     players.AddRange(FindObjectsOfType <BoardPlayer>());
     for (int i = 0; i < players.Count(); i++)
     {
         if (players[i].GamePlayer.Name == "Rape")//change this to text box entry later
         {
             me = players[i];
         }
     }
     return;
 }
 public ManipulateKeys(BoardPlayer player, String choice) //Manipulate trophies
 {
     target = player;
     if (choice == "give") //if positive, then give keys to player
     {
         //give keys to player
         giveTrophy();
     }
     else
     {
         //take keys from player
         takeTrophy();
     }
 }
Example #13
0
 //MovingObjectの抽象メソッドのため必ず必要
 protected override void OnCantMove <T>(T component)
 {
     if (component.GetComponent <BoardPlayer>())
     {
         BoardPlayer other = component as BoardPlayer;
         other.LoseHP(attackDamage);
         iTween.MoveFrom(gameObject, iTween.Hash("position", other.transform.position, "time", 0.5f));
     }
     else if (component.GetComponent <BoardBraver>())
     {
         BoardBraver other = component as BoardBraver;
         other.LoseHP(attackDamage);
     }
 }
 public ManipulateKeys(BoardPlayer player, int keys) //Give or take keys
 {
     target = player;
     if (keys > 0) //if positive, then give keys to player
     {
         //give keys to player
         giveKeys(keys);
     }
     else
     {
         //take keys from player
         takeKeys(Math.Abs(keys));
     }
 }
Example #15
0
        public TakeTurnResult TryTakeTurn(int x, int y, BoardPlayer player, out DecompressedBoardState newDecompressedState)
        {
            if (CurrentTurn == 9 || BoardResult != BoardResult.InProgress)
            {
                newDecompressedState = this;
                return(TakeTurnResult.NotInProgress);
            }

            if (player != CurrentPlayer)
            {
                newDecompressedState = this;
                return(TakeTurnResult.WrongPlayer);
            }

            int unsetIndex            = -1;
            int targetIndex           = y * 3 + x;
            int combinedBoardSnapshot = PlayerOneBoardSnapshot | PlayerTwoBoardSnapshot;

            for (int i = 0; i < 9; i++)
            {
                int snapshotIndex = 1 << i;

                if ((combinedBoardSnapshot & snapshotIndex) == 0)
                {
                    unsetIndex++;
                }

                if (targetIndex == i)
                {
                    if ((combinedBoardSnapshot & snapshotIndex) == snapshotIndex)
                    {
                        newDecompressedState = this;
                        return(TakeTurnResult.TileAlreadySet);
                    }
                    else
                    {
                        int newState = BoardHistoryUtils.SetTurn(BoardHistory, CurrentTurn, unsetIndex);
                        newDecompressedState = new DecompressedBoardState(newState);
                        return(TakeTurnResult.Success);
                    }
                }
            }

            newDecompressedState = this;
            return(TakeTurnResult.UnknownFailure);
        }
Example #16
0
    private static bool Attack(BoardPlayer player, Card actorCard, Card targetCard)
    {
        // I cannot attack on my own minions
        if (targetCard.owner == actorCard.owner)
        {
            return(false);
        }

        AttackBehaviour ab = actorCard.gameObject.AddComponent <AttackBehaviour>();

        ab.TargetCard       = targetCard;
        ab.ActorCard        = actorCard;
        ab.Player           = player;
        ab.MovingCardCanvas = player.GameManager.MovingCardCanvas;
        ab.Initialize(player.GameManager.ActionManager.AttackBehaviourConstants);


        return(true);
    }
Example #17
0
    public static void makeAction(BoardPlayer player, ActionType.TYPE actionType, Card actorCard, Card targetCard)
    {
        player.GameManager.DisablePlayerInteractions();

        switch (actionType)
        {
        case ActionType.TYPE.ATTACK:
            Attack(player, actorCard, targetCard);
            break;

        case ActionType.TYPE.BLOCK:
            Block(player, actorCard);
            break;

        case ActionType.TYPE.WAIT:
            Wait(player, actorCard);
            break;
        }

        // Actions should themselves call the player.OnActionDone()
    }
Example #18
0
        private void buttonClickAction(BoardPlayer player, String choice)
        {
            switch (choice)
            {
            case "kill": new KillPlayer(player);         //on button click kill that player
                break;

            case "give": new ManipulateKeys(player, 1);         //give 1 key to player
                break;

            case "take": new ManipulateKeys(player, -1);         //remove 1 key from a player
                break;

            case "giveTrophy": new ManipulateKeys(player, "give");         //give 1 key to player
                break;

            case "takeTrophy": new ManipulateKeys(player, "take");         //remove 1 key from a player
                break;

            case "rollNumber": new RollNumber(player, 1);         //roll a specific number on dice
                break;
            }
        }
Example #19
0
 public BoardPlayerInfo(BoardPlayer player, LudoType playerType, int startingTile)
 {
     this.player       = player;
     this.playerType   = playerType;
     this.startingTile = startingTile;
 }
 public RollNumber(BoardPlayer player, int numberToRoll)
 {
     target = player;
     forceRoll(numberToRoll);
 }
Example #21
0
 public KillPlayer(BoardPlayer player)
 {
     target = player;
     damageTarget(30);
 }
Example #22
0
 public List <Card> SpawnEnemyCards(BoardPlayer me, BoardPlayer enemy, CardDefinitionHolder[] enemyCardHolders)
 {
     return(SpawnEnemyCards(me, enemy, enemyCardHolders, enemySpawnPoints, enemyOffset));
 }
Example #23
0
    private static void Block(BoardPlayer player, Card actorCard)
    {
        actorCard.hasShield = true;

        actorCard.ShieldUp();
    }
Example #24
0
    private static void Wait(BoardPlayer player, Card actorCard)
    {
        player.GameManager.AddCardToInitiationQueue(actorCard);

        actorCard.WaitUp();
    }
Example #25
0
 private void MakePlayerMove(BoardPlayer player, int dice)
 {
 }