Пример #1
0
        public void SetPlayerBoard(Player player)
        {
            _player = player;
            _playerBoard = player.PlayerBoard;

            RefreshControls();
        }
Пример #2
0
    void OnMouseRightDown()
    {
        Debug.Log("OnMouseRightDown() - " + this.name);
        GameState   gs            = GameState.GetCurrentGameState();
        PlayerBoard currentPlayer = gs.currentPlayer;

        OnRightClick(currentPlayer);
    }
Пример #3
0
 static void printBoards(CompetitorBoard competitorBoard, PlayerBoard playerBoard)
 {
     Console.Clear();
     Console.WriteLine("Enemy board:");
     Console.WriteLine(competitorBoard);
     Console.WriteLine("\nYour board");
     Console.WriteLine(playerBoard);
 }
Пример #4
0
 public override void OnAcquireUndo(PlayerBoard plr)
 {
     base.OnAcquireUndo(plr);
     foreach(Scarab sc in scarabList)
     {
         plr.DestroyScarab(sc);
     }
 }
Пример #5
0
 public override void OnAcquireUndo(PlayerBoard plr)
 {
     base.OnAcquireUndo(plr);
     foreach (Scarab sc in scarabList)
     {
         plr.DestroyScarab(sc);
     }
 }
Пример #6
0
 //  *********************   TileAbility stuff
 public void FireTrigger(TileAbility.PlayerTurnStateTriggers trigState, PlayerBoard plr)
 {
     TileAbility[] abilityList = GetComponents<TileAbility>();
     foreach(TileAbility ability in abilityList)
     {
         ability.FireTrigger(trigState, plr);
     }
 }
Пример #7
0
    void OnMouseDown()
    {
        Debug.Log("SelectableObject.OnMouseDown()");
        GameState   gs            = GameState.GetCurrentGameState();
        PlayerBoard currentPlayer = gs.currentPlayer;

        OnSelect(currentPlayer);
    }
Пример #8
0
        // happens when equip one on top of other
        public void AllowMultipleWeaponsOnBoard()
        {
            _cards.Add(new EntityBuilder("", 3, 0)
                       .Weapon().JustPlayed().Durability(2).ToCardEntity());
            var board = new PlayerBoard(_cards, true);

            Assert.IsTrue(board.Hero.HasWeapon);
        }
Пример #9
0
 public override void OnEndOfTurn(PlayerBoard plr)
 {
     if (myDie)
     {
         if (myDie.isTemporary())
             plr.DestroyDie(myDie);
     }
 }
Пример #10
0
 void Awake()
 {
     curState               = PlayerGameStates.WaitingNextTurn;
     mayRollDice            = false;
     diceLockedThisTurn     = 0;
     lastDiceLockedThisTurn = 0;
     myPlayer               = GetComponent <PlayerBoard>();
 }
Пример #11
0
 //	does something when we select this tile
 public virtual void OnSelect(PlayerBoard plr)
 {
     GameState.Message("Tile " + this.name + " triggered OnSelect TileAbility " + this.GetType().ToString() + "\n");
     if (isArtifact)
     {
         isArtifactUsed = true;
     }
 }
Пример #12
0
    void OnMouseRightDown()
    {
        Debug.Log("DiceCup.RightClick()");
        GameState   gs            = GameState.GetCurrentGameState();
        PlayerBoard currentPlayer = gs.currentPlayer;

        currentPlayer.EndTurn();
    }
Пример #13
0
 public override void OnStartTurn(PlayerBoard plr)
 {
     base.OnStartTurn(plr);
     this.isUsedThisTurn            = false; //  refresh this every turn.
     hasBeenActivatedBySpecificRoll = false;
     curDie = null;
     adjustedDice.Clear();
 }
        protected override ActionContext DoAction(ActionContext context)
        {
            if (context.Game == null)
            {
                throw new InvalidOperationException("Action context missing required property (Game)");
            }
            if (context.Board == null)
            {
                throw new InvalidOperationException("Action context missing required property (Board)");
            }
            GameActionData actionData = MakeActionData(context);

            Game  game  = context.Game;
            Board board = context.Board;

            string[] turnOrder = game.TurnOrder;
            game.CurrentTurn++;
            game.CurrentTurn %= turnOrder.Length;
            game.turnCount++;
            game.TilesActiveThisTurn = new int[0];

            if (game.FirstPlayer != game.CurrentPlayer)
            {
                game.AddGameAction(actionData);
                return(context);
            }
            game.CurrentTurn++;
            game.CurrentTurn %= turnOrder.Length;
            game.FirstPlayer  = turnOrder[game.CurrentTurn];
            game.SunPosition  =
                (SunPosition)(((int)game.SunPosition + 1) % Enum.GetNames(typeof(SunPosition)).Length);

            if (game.SunPosition == SunPosition.NorthWest)
            {
                game.Revolution++;
                if (game.Revolution == game.LengthOfGame)
                {
                    game.Status = GameStatus.Ended;
                    game.AddGameAction(actionData);
                    context.Game  = game;
                    context.Board = board;
                    return(context);
                }
            }

            board.Tiles = Shadow.UpdateAllShadows(board, game.SunPosition);
            foreach (string playerId in game.TurnOrder)
            {
                PlayerBoard playerBoard = PlayerBoard.Get(game, playerId);
                int         earnedLight = BoardOperations.CountLight(board, playerBoard.TreeType);
                Console.WriteLine($"{playerId} - {earnedLight}");
                playerBoard.RecoverLight(earnedLight);
                game.SetPlayerBoard(playerId, playerBoard);
            }
            game.AddGameAction(actionData);
            return(context);
        }
Пример #15
0
 virtual public void OnRightClick(PlayerBoard currentPlayer)
 {
     if (isSetDie())
     {
         if (this.isUndoable)
         {
             MoveToSetDieArea();
         }
     }
 }
Пример #16
0
        public ShotResult PlayAIMove(GameField gameField = null)
        {
            gameField ??= _aiPlayer.GetGameFieldToShoot();

            var shotResult = PlayerBoard.ShootAt(gameField);

            AIBoard.AddShotResult(shotResult);

            return(shotResult);
        }
Пример #17
0
        public void DrawBoard(int xSt, int ySt)
        {
            Console.SetCursorPosition(xSt, ySt - 2);
            Console.WriteLine(" Игрок:");
            PlayerBoard.DrawBoard(xSt, ySt);

            Console.SetCursorPosition(xSt + 15, ySt - 2);
            Console.WriteLine("Противник:");
            EnemyBoard.DrawBoard(xSt + 17, ySt);
        }
Пример #18
0
 private void StartGame()
 {
     Game = new Game();
     PlayerBoard.UpdateBoard(Game.Player1.GameBoard);
     EnemyBoard.UpdateBoard(Game.Player1.EnemyBoard);
     Game.RoundCompleted.Subscribe(UpdateBoards);
     Game.GameFinished.Subscribe(GameFinished);
     EndMessage          = string.Empty;
     EnemyBoard.IsActive = true;
 }
Пример #19
0
        public ShootResultDTO MakeComputerMovement()
        {
            CheckIfGameEnded();

            var shotCoordinates = _difficulty.ChooseShotCoordinates(PlayerBoard);

            var result = PlayerBoard.Shoot(shotCoordinates.Key, shotCoordinates.Value);

            return(result);
        }
Пример #20
0
 public override void OnEndOfTurn(PlayerBoard plr)
 {
     if (myDie)
     {
         if (myDie.isTemporary())
         {
             plr.DestroyDie(myDie);
         }
     }
 }
Пример #21
0
    //接受操作
    //播放动画
    //处理流程功能
    public void Draw(PlayerBoard _turnplayer)
    {
        //切换界面
        GameObject[] container = null;
        switch (Main.Inst.lv_ctrl.map_data.my_type)
        {
        case eMapType.PvE_Solo:
            //PvE下仅一人,不做显示处理
            break;

        case eMapType.PvE_Mult:
            //PvP 正式游戏的单个客户端只显示一个人的数据
            break;

        case eMapType.PvP_2P:
            //PvP下的处理
            if (_turnplayer.ID == ePlayer.Player1)
            {
                container = Main.Inst.cardcont_p1;
                Main.Inst.player_1.setBorderOn();
                Main.Inst.player_2.setBorderOff();
            }
            else
            {
                container = Main.Inst.cardcont_p2;
                Main.Inst.player_1.setBorderOff();
                Main.Inst.player_2.setBorderOn();
            }
            Main.Inst.setHand(_turnplayer.hand_cards, container);
            break;
        }
        //回合开始秀
//		Main.Instance.TurnStart(_turnplayer.ID);

        //清空操作标记
        Main.Inst.b_attacked     = false;
        Main.Inst.b_moving_chess = false;

        //玩家抽牌逻辑
        if (_turnplayer.hand_cards.Count < 5)
        {
            if (!_turnplayer.orenotan_draw())
            {
                Debug.Log("牌堆没牌了");
                //return;
            }
            //removeCard((Card)_turnplayer.hand_cards[0]);
        }
        Main.Inst.b_setchess = false;
        Main.Inst.setHand(_turnplayer.hand_cards, container);
        //clickCardContainer(container[0].GetComponent<CardContainer>());

        Main.Inst.b_phase_trigger = true;
        Main.Inst.now_phase_type++;
    }
Пример #22
0
    //   a click on the Dice Cup means the player may want to roll dice OR end the turn
    void OnMouseDown()
    {
        Debug.Log("DiceCup.OnMouseDown()");
        GameState   gs            = GameState.GetCurrentGameState();
        PlayerBoard currentPlayer = gs.currentPlayer;

        if (currentPlayer.RollDice())               //  attempt to roll dice
        {
            StartRolling();
        }
        //  otherwise, if no dice were rolled, it implies end of turn
    }
Пример #23
0
        protected override ActionContext DoAction(ActionContext context)
        {
            if (context.Game == null)
            {
                throw new InvalidOperationException("Action context missing required property (Game)");
            }

            if (context.Board == null)
            {
                throw new InvalidOperationException("Action context missing required property (Board)");
            }

            if (context.Origin == null)
            {
                throw new InvalidOperationException("Action context missing required property (Origin)");
            }

            if (context.Target == null)
            {
                throw new InvalidOperationException("Action context missing required property (Target)");
            }

            GameActionData actionData = MakeActionData(context);

            Game   game     = context.Game;
            Board  board    = context.Board;
            Hex    origin   = context.Origin.Value;
            string playerId = context.PlayerId;

            int         tileCode        = board[origin];
            int         growingTypeCode = (int)(Tile.GetPieceType(tileCode) ?? 0);
            int         grownTypeCode   = growingTypeCode + 1;
            int         price           = grownTypeCode;
            PlayerBoard playerBoard     = PlayerBoard.Get(game, playerId);

            playerBoard.Pieces((PieceType)grownTypeCode).DecreaseAvailable();
            int resultingTile = Tile.SetPieceType(tileCode, (PieceType)grownTypeCode);

            playerBoard.Pieces((PieceType)growingTypeCode).IncreaseOnPlayerBoard();
            playerBoard.SpendLight(price);
            game.SetPlayerBoard(playerId, playerBoard);
            board[origin] = resultingTile;
            board.Tiles   = Shadow.UpdateAllShadows(board, game.SunPosition);

            game.TilesActiveThisTurn =
                game.TilesActiveThisTurn.Where(h => h != origin.HexCode).Append(origin.HexCode).ToArray();

            game.AddGameAction(actionData);
            context.Game  = game;
            context.Board = board;

            return(context);
        }
Пример #24
0
 public override void OnSelect(PlayerBoard plr)
 {
     if (!isArtifactUsed)
     {
         base.OnSelect(plr);
         OnAcquire(plr); //  do the same thing as acquire.
     }
     else
     {
         GameState.Message("Artifact " + this.name + " has already been used this game.");
     }
 }
Пример #25
0
 public override void OnSelect(PlayerBoard plr)
 {
     if (!isArtifactUsed)
     {
         base.OnSelect(plr);
         OnAcquire(plr); //  do the same thing as acquire.
     }
     else
     {
         GameState.Message("Artifact " + this.name + " has already been used this game.");
     }
 }
Пример #26
0
    PlayerBoard NextPlayer()
    {
        int idx = GetPlayerIndex(currentPlayer);

        idx++;
        if (idx >= allPlayers.Count)
        {
            idx = 0;
        }
        PlayerBoard nextPlr = allPlayers [idx];

        return(nextPlr);
    }
Пример #27
0
        public ResourceSegment(PopulationType type, PlayerBoard board)
        {
            var msg = "Storage: {0}[placeholder]</br>Production: {1}</br>Next Production: {2}";
            msg = String.Format(msg, board.GetStorage(type), board.GetProduction(type), board.GetNextProduction(type));
            if (type == PopulationType.Money)
               msg= msg.Replace("[placeholder]", "</br>Production less upkeep: " + (board.GetProduction(PopulationType.Money) - board.GetUpkeep()).ToString());
            else
                msg = msg.Replace("[placeholder]", "");

            Description = msg;

            Name = type.ToString();
        }
Пример #28
0
    void NewGame(int numPlrs)
    {
        Message("Starting new game with " + numPlrs.ToString() + " players.");
        foreach (PlayerBoard plr in allPlayers)
        {
            plr.NewGame();
        }
        int rndIndex = (int)(Random.value * (float)allPlayers.Count);

        currentPlayer = allPlayers [rndIndex];
        currentPlayer.SetStartPlayer();
        StartTurn();
    }
        protected override ActionContext DoAction(ActionContext context)
        {
            if (context.Game == null)
            {
                throw new InvalidOperationException("Action context missing required property (Game)");
            }

            if (context.Board == null)
            {
                throw new InvalidOperationException("Action context missing required property (Board)");
            }

            if (context.Origin == null)
            {
                throw new InvalidOperationException("Action context missing required property (Origin)");
            }

            if (context.Target == null)
            {
                throw new InvalidOperationException("Action context missing required property (Target)");
            }

            GameActionData actionData = MakeActionData(context);

            string playerId = context.PlayerId;
            Game   game     = context.Game;
            Board  board    = context.Board;
            Hex    origin   = (Hex)context.Origin;

            PlayerBoard playerBoard = PlayerBoard.Get(game, playerId);

            Scoring.Token[] playerScore = game.Scores[playerId];
            playerBoard.SpendLight(4);
            board[origin] = Tile.Empty;
            playerBoard.Pieces(PieceType.LargeTree).IncreaseOnPlayerBoard();
            if (ScoreTokens.Take(game, origin, out Scoring.Token? token))
            {
                if (token != null)
                {
                    game.Scores[playerId] = playerScore !.Append(token).ToArray();
                }
            }

            PlayerBoard.Set(game, playerId, playerBoard);
            board.Tiles = Shadow.UpdateAllShadows(board, game.SunPosition);
            game.TilesActiveThisTurn =
                game.TilesActiveThisTurn.Where(h => h != origin.HexCode).Append(origin.HexCode).ToArray();

            game.AddGameAction(actionData);
            return(context);
        }
Пример #30
0
        public BuyAction(Params actionParams) : base(actionParams)
        {
            (ActionRequest request, string playerId, Game? game, _, _) = actionParams;
            Game = game !;
            PieceType pieceType = (PieceType)request.PieceType !;
            int       cost      = PlayerBoard.Get(Game, playerId).Pieces(pieceType).NextPrice;

            AddValidators(
                new AActionValidator[] {
                new PlayerHasPieceOnPlayerBoard(playerId, pieceType, Game),
                new PlayerCanAffordCost(PlayerId, cost, Game),
            }
                );
        }
Пример #31
0
    int GetPlayerIndex(PlayerBoard match_plr)
    {
        int idx = -1;

        foreach (PlayerBoard plr in allPlayers)
        {
            idx++;
            if (plr == match_plr)
            {
                return(idx);
            }
        }
        return(idx);
    }
Пример #32
0
    public override void OnLockedAny(PlayerBoard plr)
    {
        base.OnLockedAny(plr);
        //  check to see if the player already has a Herder Die
        if (plr.hasHerderDie()) return; //  early bail. Probably print some sort of message and give the scarab tokens.

        //  check to see if the player has a locked pair
        //  if so, do the same thing as acquire
        if (isQualified())
        {
            myDie = GetNewDie(plr);
            plr.GiveHerderDie(myDie);
        }
    }
Пример #33
0
    //  this calls the actual delegates for the triggers
    public virtual void ActualFireTrigger(PlayerTurnStateTriggers trig, PlayerBoard plr)
    {
        switch (trig)
        {
        default:
        case PlayerTurnStateTriggers.OnSpecificRoll:        //  my die has rolled. Send the trigger of what that roll was so that the TileAbility may react to it.
            int dieRoll = this.myDie.GetValue();
            OnSpecificDie(dieRoll);
            break;

        case PlayerTurnStateTriggers.NoTrigger:
            break;

        case PlayerTurnStateTriggers.StartOfRoll:
            OnStartRoll(plr);
            break;

        case PlayerTurnStateTriggers.StartOfTurn:
            OnStartTurn(plr);
            break;

        case PlayerTurnStateTriggers.EndOfTurn:
            OnEndOfTurn(plr);
            break;

        case PlayerTurnStateTriggers.AllLocked:
            OnAllLocked(plr);
            break;

        case PlayerTurnStateTriggers.Acquire:
            OnAcquire(plr);
            break;

        case PlayerTurnStateTriggers.AcquireUndo:
            OnAcquireUndo(plr);
            break;

        case PlayerTurnStateTriggers.Select:
            OnSelect(plr);
            break;

        case PlayerTurnStateTriggers.ChooseDie:
            OnChooseDie(plr);
            break;

        case PlayerTurnStateTriggers.LockedAny:
            OnLockedAny(plr);
            break;
        }
    }
Пример #34
0
        }                                                           // UpdatePlayer output

        private void LoadBoards()
        {
            var xmlSerializer = new ExtendedXmlSerializer(string.Empty);

            InitialGameMasterBoard =
                xmlSerializer.DeserializeFromXmlFile <GameMasterBoard>(ScenarioFileBase + GMInitialSufix);
            UpdatedGameMasterBoard =
                xmlSerializer.DeserializeFromXmlFile <GameMasterBoard>(ScenarioFileBase + GMUpdatedSufix);

            InitialPlayerBoard =
                xmlSerializer.DeserializeFromXmlFile <PlayerBoard>(ScenarioFileBase + PlayerInitialSufix);
            UpdatedPlayerBoard =
                xmlSerializer.DeserializeFromXmlFile <PlayerBoard>(ScenarioFileBase + PlayerUpdatedSufix);
        }
Пример #35
0
        public WinnerType GetWinner()
        {
            if (AIBoard.AllShipsAreSunk())
            {
                return(WinnerType.Player);
            }

            if (PlayerBoard.AllShipsAreSunk())
            {
                return(WinnerType.Computer);
            }

            return(WinnerType.None);
        }
Пример #36
0
        public void CalculateEndGameBonus_Unocupplied()
        {
            //Arrange
            var cityHall = new CityHall();

            cityHall.Occupation.Add(false);
            var playerBoard = new PlayerBoard(null);

            playerBoard.CitySpaces.Add(cityHall);
            //Act
            var result = cityHall.CalculateEndGameBonus(playerBoard);

            //Assert
            Assert.AreEqual(result, 0);
        }
Пример #37
0
        public ComputerAttackResult AttackPlayer()
        {
            ComputerAttackResult compu = new ComputerAttackResult();

            compu.Row    = RandomManager.GetNext(0, PlayerBoard.Size);
            compu.Col    = RandomManager.GetNext(0, PlayerBoard.Size);
            compu.Result = PlayerBoard.Attack(new Location(compu.Row, compu.Col));
            while (compu.Result == AttackResult.repeat)
            {
                compu.Row    = RandomManager.GetNext(0, PlayerBoard.Size);
                compu.Col    = RandomManager.GetNext(0, PlayerBoard.Size);
                compu.Result = PlayerBoard.Attack(new Location(compu.Row, compu.Col));
            }
            return(compu);
        }
Пример #38
0
    List<Scarab> scarabList; //    the scarab that is associated with this tile.

    #endregion Fields

    #region Methods

    //    does something when we acquire this tile
    public override void OnAcquire(PlayerBoard plr)
    {
        base.OnAcquire(plr);
        if (doubleCurrentTokens_Ankh)
        {
            nScarabs = plr.CountScarabs();
        }

        for (int ii = 0; ii < nScarabs; ii++)
        {
            rndType = (Scarab.ScarabType)Random.Range(0, 2);
            Scarab bug = plr.AddScarab(rndType);
            scarabList.Add(bug);
            bug.name = "Scarab " + rndType.ToString();
        }
    }
Пример #39
0
    public override void OnSelect(PlayerBoard plr)
    {
        base.OnSelect(plr);
        if (this.isUsedThisTurn && this.onlyOneUsePerTurn)
        {
            GameState.Message("Already used " + this.name + "\nduring this turn.");
            return;
        }
        if (this.isUsedThisRoll)
        {
            GameState.Message("Already used " + this.name + "\nduring this roll.");
            return;

        }
        //  sometimes, this is a DieAbility rather than a TileAbility.  SOme die abilities only are allowed on certain rolls of that die.
        if (specificRoll > 0)
        {
            if (this.myDie != null)
            {
                if (this.myDie.GetValue() != specificRoll)
                {
                    GameState.Message("Die " + this.myDie.name + " must be " + specificRoll.ToString() + " to use this ability.\n");
                    return;
                }
            }
        }
        curDie = null;
        adjustedDice.Clear();
        if (nDice == -1)
        {
            actualNumDice = plr.GetNumValidDice(onlyFor);
        }
        else
        {
            actualNumDice = nDice;
        }
        myPlayer = plr;
        plr.SetTileInUse(this.GetComponent<Tile>());
        plr.AskToChooseDie(this.PickDie, this.GetType().ToString()); //  ask the player to choose a die or dice
        plr.AskToChooseCancel(this.OnCancel);
        plr.AskToChooseDone(this.OnDone);
    }
Пример #40
0
 //  this calls the actual delegates for the triggers
 public virtual void ActualFireTrigger(PlayerTurnStateTriggers trig, PlayerBoard plr)
 {
     switch (trig)
     {
         default:
         case PlayerTurnStateTriggers.OnSpecificRoll:    //  my die has rolled. Send the trigger of what that roll was so that the TileAbility may react to it.
             int dieRoll = this.myDie.GetValue();
             OnSpecificDie(dieRoll);
             break;
         case PlayerTurnStateTriggers.NoTrigger:
             break;
         case PlayerTurnStateTriggers.StartOfRoll:
             OnStartRoll(plr);
             break;
         case PlayerTurnStateTriggers.StartOfTurn:
             OnStartTurn(plr);
             break;
         case PlayerTurnStateTriggers.EndOfTurn:
             OnEndOfTurn(plr);
             break;
         case PlayerTurnStateTriggers.AllLocked:
             OnAllLocked(plr);
             break;
         case PlayerTurnStateTriggers.Acquire:
             OnAcquire(plr);
             break;
         case PlayerTurnStateTriggers.AcquireUndo:
             OnAcquireUndo(plr);
             break;
         case PlayerTurnStateTriggers.Select:
             OnSelect(plr);
             break;
         case PlayerTurnStateTriggers.ChooseDie:
             OnChooseDie(plr);
             break;
         case PlayerTurnStateTriggers.LockedAny:
             OnLockedAny(plr);
             break;
     }
 }
Пример #41
0
 protected override void SetupStorage(PlayerBoard board)
 {
     board.MoneyStorage = board.ScienceStorage = 3;
     board.MaterialsStorage = 5;
 }
Пример #42
0
 public override void OnChooseDie(PlayerBoard plr)
 {
     base.OnChooseDie(plr);
 }
Пример #43
0
 public override void OnStartTurn(PlayerBoard plr)
 {
     base.OnStartTurn(plr);
     myDie = GetNewDie(plr);
 }
Пример #44
0
 //  does something on the start of each turn
 public virtual void OnStartTurn(PlayerBoard plr)
 {
     GameState.Message("Tile " + this.name + " triggered OnStartTurn TileAbility " + this.GetType().ToString() + "\n");
 }
Пример #45
0
 public override void OnStartRoll(PlayerBoard plr)
 {
     this.isUsedThisRoll = false;
 }
Пример #46
0
 //  returns true - if trigger is allowed to fire its delegate
 //  returns false - if trigger is not selected as one of the allowed triggers
 public virtual bool FilterTriggers(PlayerTurnStateTriggers trig, PlayerBoard plr)
 {
     bool isAllowed = false;
     if (onStateTrigger==PlayerTurnStateTriggers.AllTrigger) isAllowed = true;
     if (trig == PlayerTurnStateTriggers.AcquireUndo) isAllowed = true;
     if (trig == onStateTrigger) isAllowed = true;
     foreach(PlayerTurnStateTriggers testTrig in fireOnTriggerList)
     {
         if (testTrig == trig) isAllowed = true;
     }
     return isAllowed;
 }
Пример #47
0
 //    does something when we select this tile
 public virtual void OnSelect(PlayerBoard plr)
 {
     GameState.Message("Tile " + this.name + " triggered OnSelect TileAbility " + this.GetType().ToString() + "\n");
     if (isArtifact)
         isArtifactUsed = true;
 }
Пример #48
0
 void Awake()
 {
     curState = PlayerGameStates.WaitingNextTurn;
     mayRollDice = false;
     diceLockedThisTurn = 0;
     lastDiceLockedThisTurn = 0;
     myPlayer = GetComponent<PlayerBoard>();
 }
Пример #49
0
 public override void OnStartTurn(PlayerBoard plr)
 {
     base.OnStartTurn(plr);
     OnAcquire(plr); //  do the same thing as acquire.
 }
Пример #50
0
 public void OnAcquire(PlayerBoard plr)
 {
     TileAbility[] abilities = GetComponents<TileAbility>();
     foreach(TileAbility ability in abilities) {
         ability.OnAcquire(plr);
     }
 }
Пример #51
0
 public override void OnAcquireUndo(PlayerBoard plr)
 {
     base.OnAcquireUndo(plr);
     plr.DestroyDie(myDie);
     myDie = null;
 }
Пример #52
0
 public override void OnStartTurn(PlayerBoard plr)
 {
     base.OnStartTurn(plr);
     this.isUsedThisTurn = false;    //  refresh this every turn.
     hasBeenActivatedBySpecificRoll = false;
     curDie = null;
     adjustedDice.Clear();
 }
Пример #53
0
    //  received a type of trigger from somewhere. If this TileAbility is listening for it, then fire it off using the appropriate delegate
    //  AllTrigger - listens to all triggers and fires off delegates (if any) on all of them.
    //  AcquireUndo - is a system level trigger and must always fire.
    public virtual void FireTrigger(PlayerTurnStateTriggers trig, PlayerBoard plr)
    {
        /*  //  old logic
        if (onStateTrigger != PlayerTurnStateTriggers.AllTrigger)   //  if we trigger on all triggers, ignore this bail.
        {
            if (trig != PlayerTurnStateTriggers.AcquireUndo)  //  undo does not bail but always goes through
            {
                if (onStateTrigger != trig) return; //  bail if it's not the right trigger.
            }
        }
        */
        bool allowTriggerToFire = FilterTriggers(trig, plr);

        if (allowTriggerToFire)
            ActualFireTrigger(trig, plr);
    }
Пример #54
0
 public virtual void OnSelect(PlayerBoard currentPlayer)
 {
     Debug.Log("SelectableObject.OnSelect():" + this.gameObject.name + " by: " + currentPlayer.name);
 }
Пример #55
0
    //  get a new die that is ready to roll immediately
    PharoahDie GetNewDie(PlayerBoard plr)
    {
        PharoahDie die = plr.AddDie(type);
        myDie = die;    //  remember the die that this tileAbility bought. We may need to do something with it later.
        if (setDieValue > 0)
        {
            die.MakeSetDie(setDieValue);
        }
        if (isTemporary)
            die.MakeTemporary();

        return die;
    }
Пример #56
0
 //    does something when we acquire this tile
 public override void OnAcquire(PlayerBoard plr)
 {
     base.OnAcquire(plr);
     myDie = GetNewDie(plr);
     myDie.PurchasedDie(this);
 }
Пример #57
0
    public override void OnSelect(PlayerBoard currentPlayer)
    {
        base.OnSelect(currentPlayer);
        if (GameState.GetCurrentGameState().CheatModeEnabled)
        {
            //  if the player does not have this tile and we're not in a slot and we're in cheat mode, then acquire this tile temporarily because it's probably for testing.
            if (!currentPlayer.Has(this) && !mySlot)
            {
                //  minghack: Put this tile into the player's temporary tile stack so that we may test loose tiles easily.
                GameState.Message("Cheat:" + currentPlayer.name + " adds temp tile" + this.name);
                currentPlayer.AddTempTile(this);
            }
        }
        if (currentPlayer.Has(this)) {
            if (this.canUndo)
            {
                this.ReturnToSlot();
                currentPlayer.Drop(this);
            }
            else if (this.canActivate())
            {
                this.FireTrigger(TileAbility.PlayerTurnStateTriggers.Select, currentPlayer);
            }
        }
        else {
            bool bQualifiedToPurchase = false;
            if (mySlot)
            {
                bQualifiedToPurchase = mySlot.isQualified();
            }
            else
            {
                Debug.LogError("No Slot found for Tile " + this.name);
            }

            if (bQualifiedToPurchase) {
                bool bGotOne = mySlot.HasOne();
                if (bGotOne) {
                    bool bSuccessfulTake = currentPlayer.Take(this);
                    if (bSuccessfulTake)
                        mySlot.TakeOne();
                }
                else {
                    GameState.Message(mySlot.name + " is out of " + this.name + " so " + currentPlayer.name + " got none!");
                }
            }
            else {
                //string msg = (mySlot.name + " is not qualified to buy " + this.name + "\nbecause it didn't satisfy" + mySlot.name);
                string msg = "";
                if (mySlot)
                {
                    msg = ("Cannot claim " + this.name + "\nbecause locked dice did not satisfy\n" + mySlot.name);
                }
                else
                {
                    msg = this.name + " was not in a slot.";
                }
                GameState.Message(msg);
            }
        }
    }