Ejemplo n.º 1
0
	public void RespawnPlayer(PlayerType playerType){
		if (this){
			if (isActiveAndEnabled){
				StartCoroutine(RespawnMeInLevel(playerType));
			}
		}
	}
Ejemplo n.º 2
0
        public Player(int playerNumber, PlayerType type)
        {
            this.playerNumber = playerNumber;

            this.currentPosition = null;
            this.possibleMoves = Move.getPossibleMoves(Core.drawCube.cube, currentPosition);

            this.type = type;

            if (type == PlayerType.AI)
            {
                switch (playerNumber)
                {
                    case 1:

                        setAIFunc(Config.getValue("ai", "player_one"));
                        break;

                    case 2:

                        setAIFunc(Config.getValue("ai", "player_two"));
                        break;
                }
            }
        }
Ejemplo n.º 3
0
 public Player(String id, List<Card> cards, Card currentCard, PlayerType playerType)
 {
     this.id = id;
     this.cards = cards;
     this.currentCard = currentCard;
     this.playerType = playerType;
 }
Ejemplo n.º 4
0
Archivo: Player.cs Proyecto: Jh87S/TLN
 // CONSTRUCTORS
 public Player(PlayerType type, int spriteWidht, int spriteHeight)
 {
     if (type == PlayerType.Hero)
     {
         this.Hitbox = new Rectangle(120, 120, spriteWidht, spriteHeight);
         this.FrameLine = 1;
         this.FrameColumn = 3;
         this.Effects = SpriteEffects.None;
         this.Direction = Direction.Down;
         this.Animation = true;
         this.Timer = 0;
     }
     if (type == PlayerType.Ennemy)
     {
         this.IAHitbox = new Rectangle(120, 120, spriteWidht, spriteHeight);
         this.FrameLine = 1;
         this.FrameColumn = 3;
         this.Effects = SpriteEffects.None;
         this.Direction = Direction.Down;
         this.Animation = true;
         this.Timer = 0;
     }
     if (type == PlayerType.Munition)
     {
         this.MuniHitbox = new Rectangle(120, 120, spriteWidht, spriteHeight);
         this.FrameLine = 1;
         this.FrameColumn = 3;
         this.Effects = SpriteEffects.None;
         this.Direction = Direction.Down;
         this.Animation = true;
         this.Timer = 0;
     }
 }
Ejemplo n.º 5
0
 public Engine(PlayerType playerType, IUserInterface inputInterface)
 {
     this.PlayerType = playerType;
     this.rnd = new Random();
     this.inputInterface = inputInterface;
     this.AllObjects = new List<WorldObject>();
 }
    public static GameObject GetPrefabInstanceFromType( PlayerType type )
    {
        string objectName;
        switch (type) {
            case PlayerType.PLAYER:
                objectName = "PlayerNormal";
                break;
            case PlayerType.MONSTER:
                objectName = "Toothy";
                break;
            case PlayerType.AI_MONSTER:
                objectName = "AIToothy";
                break;
            case PlayerType.AI_PLAYER:
                objectName = "AIPlayerNormal";
                break;
            default:
                objectName = "AIPlayerNormal";
                break;
        }

        string localPath = "Prefabs/Characters/" + objectName;
        Object localInstance = Resources.Load<GameObject>( localPath );
        GameObject instance = Instantiate( localInstance ) as GameObject;

        return instance;
    }
Ejemplo n.º 7
0
        public static ReversiPlayer Create(PlayerType type, int color)
        {
            switch (type)
            {
                case PlayerType.MiniMax1:
                    return new ReversiPlayer(color, new MinMaxStrategy(new ScoreAndCornersEvaluator(), 2, color));

                case PlayerType.MiniMax2:
                    return new ReversiPlayer(color, new MinMaxStrategy(new ScoreAndCornersEvaluator(), 4, color));

                case PlayerType.MiniMax25:
                    return new ReversiPlayer(color, new MinMaxStrategy(new ScoreAndCornersEvaluator(), 5, color));

                case PlayerType.MiniMax3:
                    return new ReversiPlayer(color, new MinMaxStrategy(new ScoreAndCornersEvaluator(), 6, color));

                case PlayerType.Random:
                    return new ReversiPlayer(color, new RandomStrategy());

                case PlayerType.AlwaysFirst:
                    return new ReversiPlayer(color, new AlwaysFirstStrategy());

                case PlayerType.Minimax2WithoutCorners:
                    return new ReversiPlayer(color, new MinMaxStrategy(new ScoreEvaluator(), 2, color));
                case PlayerType.DynamicMinmax:
                    return new ReversiPlayer(color, new DynamicMinMaxStrategy(color));
                default:
                    return null;
            }
        }
Ejemplo n.º 8
0
    public virtual void ChangeRole(PlayerType newRole, bool respawn = false)
    {
        Debug.Log(this.gameObject.name + " Change type from: "+this.Type +" to: " + newRole);

        // Set new role
        this.Type = newRole;
    }
Ejemplo n.º 9
0
        private void PlaceMark(PlayerType mark, int row, int col)
        {
            if (CurrentTurn != mark)
            {
                throw new OutOfTurnException();
            }

            if (row < 0 || row > 2)
            {
                throw new ArgumentOutOfRangeException("row");
            }
            if (col < 0 || col > 2)
            {
                throw new ArgumentOutOfRangeException("col");
            }

            if (_squares[row, col] != PlayerType.None)
            {
                throw new InvalidOperationException("A mark has already been placed at that position.");
            }

            _squares[row, col] = mark;

            CheckIfLastMoveEndsGame(row, col);
            ChangeTurns();
        }
Ejemplo n.º 10
0
    private void OnPlayerDied(PlayerType param)
    {
        _advanceCountdown = advanceLevelDelayLevelDeath;
        _nextLevelName = _levelSequence[_currentLevel];

        CameraFade.StartAlphaFade(Color.black, false, _advanceCountdown, 2f, () => { Application.LoadLevel(_nextLevelName); });
    }
Ejemplo n.º 11
0
 public Game(ref Player playerA,ref Player playerB,Difficulty difficulty,GameMode gameMode)
 {
     current_game = this;
     board = new PlayerType[3,3]{{PlayerType.NONE,PlayerType.NONE,PlayerType.NONE},
                                 {PlayerType.NONE,PlayerType.NONE,PlayerType.NONE},
                                 {PlayerType.NONE,PlayerType.NONE,PlayerType.NONE}};
     this.playerA = playerA;
     this.playerA.score = 0;
     this.playerB = playerB;
     this.difficulty = difficulty;
     this.game_mode = gameMode;
     if (game_mode == GameMode.SINGLE_PLAYER)
     {
         //playerA.name = "User";
         playerB.name = "Computer";
         playerA.moveAllowed = true;
         playerB.moveAllowed = false;
     }else if(game_mode == GameMode.MULTI_PLAYER_STANDALONE){
         //playerA.name = "Ball";
         playerB.name = "Cross";
         //playerA.moveAllowed = true;
         playerB.moveAllowed = false;
         this.difficulty = Difficulty.NONE;
     }
     else if (game_mode == GameMode.MULTI_PLAYER)
     {
         this.difficulty = Difficulty.NONE;
     }
     this.current_player = playerA;
     this.connected = false;
 }
Ejemplo n.º 12
0
        public ThreadedLimakeGame(PlayerType Green, PlayerType Red, PlayerType Blue, PlayerType Yellow)
        {
            beersDrunk = new int[5];

            IPlayer[] players = new IPlayer[] { GetPlayer(Green), GetPlayer(Red), GetPlayer(Blue), GetPlayer(Yellow) };
            game = new Game(this, players);
        }
Ejemplo n.º 13
0
 public PlayerFactory(PlayerType playerType, string url)
 {
     PreparedPlayerType = playerType;
     PreparedUrl = url;
     SelectPlayerType();
     PreparePlayer();
 }
Ejemplo n.º 14
0
	public void SetControls(PlayerType playerType){
		if (playerType == PlayerType.Explo){
			horizontal = "P1_Horizontal";
			vertical = "P1_Vertical";
			action = "P1_Action";
			jump = "P1_Jump";
			pause = "P1_Pause";
			toss = "P1_Toss";
			door = "P1_Door";
			toggleCamera = "P1_ToggleCamera";
			restart = "P1_Restart";
			isExplo = true;
		}
		else if (playerType == PlayerType.Implo){
			horizontal = "P2_Horizontal";
			vertical = "P2_Vertical";
			action = "P2_Action";
			jump = "P2_Jump";
			pause = "P2_Pause";
			toss = "P2_Toss";
			door = "P2_Door";
			toggleCamera = "P2_ToggleCamera";
			restart = "P2_Restart";
			isExplo = false;
		}
	}
Ejemplo n.º 15
0
        public Empire(string emperorName, int empireID, Race race, PlayerType type, Color color, GameMain gameMain)
            : this()
        {
            Reserves = 0;
            TaxRate = 0;
            this.empireName = emperorName;
            this.empireID = empireID;
            this.type = type;
            EmpireColor = color;
            try
            {
                TechnologyManager.SetComputerTechs(gameMain.MasterTechnologyManager.GetRandomizedComputerTechs());
                TechnologyManager.SetConstructionTechs(gameMain.MasterTechnologyManager.GetRandomizedConstructionTechs());
                TechnologyManager.SetForceFieldTechs(gameMain.MasterTechnologyManager.GetRandomizedForceFieldTechs());
                TechnologyManager.SetPlanetologyTechs(gameMain.MasterTechnologyManager.GetRandomizedPlanetologyTechs());
                TechnologyManager.SetPropulsionTechs(gameMain.MasterTechnologyManager.GetRandomizedPropulsionTechs());
                TechnologyManager.SetWeaponTechs(gameMain.MasterTechnologyManager.GetRandomizedWeaponTechs());
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }

            EmpireRace = race;
        }
Ejemplo n.º 16
0
        private String tileName; // The path to image file

        #endregion Fields

        #region Constructors

        public Door(Game game, Point pos, String tileName, PlayerType pt)
            : base(game, pos)
        {
            this.tileName = tileName;
            collisionManager.RegisterObject(this);
            playerType = pt;
        }
Ejemplo n.º 17
0
 public void AddToGame(AbstractGame game, PlayerType playerType)
 {
     _game = game;
     _playerType = playerType;
     AbstractGame.StepHandler stepHandler = AlfaBetaStepHandler;
     game.RegisterAsPlayer(ref stepHandler, playerType);
 }
Ejemplo n.º 18
0
        public Player(List<Player> players, OutputType outputType)
        {
            writer = new Output(outputType);
            writer.Write("Enter the name of the player: ");
            this.name = Console.ReadLine().Trim();

            writer.Write("Enter the piece you want to use: ");
            this.piece = new Piece(Console.ReadLine().Trim());
            while (players.Select(p => p).Where(x => string.Compare(x.Piece.Symbol, this.piece.Symbol) == 0).Count() >= 1)
            {
                writer.Write("That piece has already been taken.\nChoose a different piece: ");
                this.piece = new Piece(Console.ReadLine().Trim());
            }

            writer.Write("Is this player HUMAN or AI: ");
            do
            {
                var playerType = Console.ReadLine().Trim();
                PlayerType humanOrNot;
                if (Enum.TryParse<PlayerType>(playerType.ToUpper(), out humanOrNot))
                {
                    this.playerType = humanOrNot;
                    break;
                }
                writer.Write("Enter a valid Player Type: [human] or [AI]: ");
                continue;
            } while (true);

            this.order = -1;
        }
Ejemplo n.º 19
0
 public static Player getPlayer(PlayerType name)
 {
     switch (name) {
     case PlayerType.Boring:
         return new PlayerBoring ();
         break;
     case PlayerType.Logic:
         return new PlayerLogic ();
         break;
     case PlayerType.MinMax:
         return new PlayerMinMax ();
         break;
     case PlayerType.NeuralBlank:
         return new PlayerNeural (createNetwork ());
         break;
     case PlayerType.NeuralLoad:
         return new PlayerNeural (loadNetwork ());
         break;
     case PlayerType.Random:
         return new PlayerRandom ();
         break;
     case PlayerType.Human:
         return new PlayerHuman ();
         break;
     }
     return new PlayerBoring ();
 }
Ejemplo n.º 20
0
    public void Impulse(PlayerType type)
    {
        if (type == PlayerType.Left)
            StartCoroutine(Impulsing(m_LeftImpulse));

        if (type == PlayerType.Right)
            StartCoroutine(Impulsing(m_RightImpulse));
    }
Ejemplo n.º 21
0
        /// <summary>
        /// Plays a turn
        /// </summary>
        /// <param name="playerType">Player type</param>
        /// <param name="row">Row in which to play. Use 0-2</param>
        /// <param name="column">Column in which to play. Use 0-2</param>
        public void PlayTurn(PlayerType playerType, int row, int column)
        {
            ValidateTurn(playerType, row, column);

            Board[row, column] = playerType;
            previousPlayer = playerType;
            return;
        }
Ejemplo n.º 22
0
 /// <summary>
 /// Server init without client
 /// </summary>
 /// <param name="type">0-Server; 1-Client</param>
 /// <param name="port"></param>
 public NetInterection(PlayerType type, string port)
 {
     if (type == PlayerType.ptClient)
         throw new Exception();
         // server = new TcpListener(System.Net.Dns.GetHostEntry(Dns.GetHostName()).AddressList[1], int.Parse(port));
         server = new TcpListener(int.Parse(port));
         server.Start();
 }
Ejemplo n.º 23
0
 public PlayerData(int id, int carType, ControlScheme ctrlScheme, PlayerType playerType)
 {
     _carType = carType;
     _ctrlScheme = ctrlScheme;
     _playerType = playerType;
     _lives = 10;
     ID = id;
 }
 public ChooseStreamingEndpoint(CloudMediaContext context, IAsset asset, string filter = null, PlayerType playertype =PlayerType.AzureMediaPlayer)
 {
     InitializeComponent();
     this.Icon = Bitmaps.Azure_Explorer_ico;
     _context = context;
     _asset = asset;
     _filter = filter;
     _playertype = playertype;
 }
        public bool IsMoveValid(int fromRow, int fromColumn, int toRow, int toColumn, PieceType fromPieceType,
            PieceType toPieceType, PlayerType playerInTurn)
        {
            if (IsJumping(fromRow, fromColumn, toRow, toColumn)) return false;
            if (!IsOriginValid(fromPieceType, playerInTurn)) return false;
            if (!IsMovingForward(fromRow, toRow, playerInTurn)) return false;

            return IsDestinationValid(fromColumn, toColumn, toPieceType, playerInTurn);
        }
Ejemplo n.º 26
0
	public TcpPlayer (Socket s , int _id , PlayerType _type)	 : base(_id, _type)	
	{			
		socket = s;
		ThreadStart ts = new ThreadStart(ListenPlayer);
		tread = new Thread(ts);		
		tread.Start();

		SendWelcomeValues();
	}	
Ejemplo n.º 27
0
 internal BasePlayer(PlayerType setPlayerType)
 {
     Name = "Player";
      Race = Game.Race.Humans;
      PlayerType = setPlayerType;
      Entities = new List<Entity> ();
      Gold = 0;
      Lumber = 0;
 }
Ejemplo n.º 28
0
    private void AddNewPlayerAsChildAndDisable(PlayerType type)
    {
        GameObject player = (GameObject) Instantiate(Resources.Load("Players" + "/" + type.ToString()));
        player.transform.parent = transform;
        player.transform.localPosition = Vector3.zero;
        player.SetActive(false);

        playerHT[type] = player;
    }
Ejemplo n.º 29
0
    private void SpawnPiece(PlayerType p, PieceType t, Position pos, Transform parent)
    {
        GameObject go = Instantiate(piecePrefab) as GameObject;
        Piece piece = go.GetComponent<Piece>();
        go.transform.parent = parent;

        piece.Set(p, t, pos);
        GameController.Instance.board.GetField(pos).Occupy(piece);
    }
Ejemplo n.º 30
0
        /// <summary>
        /// Client init
        /// </summary>
        /// <param name="type">0-Server; 1-Client</param>
        /// <param name="ip"></param>
        /// <param name="port"></param>
        public NetInterection(PlayerType type, string ip, string port)
        {
            if (type == PlayerType.ptServer)
                throw new Exception();

            client = new TcpClient(ip, int.Parse(port));
            stream = client.GetStream();
            connected = true;
        }
Ejemplo n.º 31
0
 public bool ExistKingOnBoard(PlayerType player)
 {
     return(FindKingOnBoard(player) != null);
 }
Ejemplo n.º 32
0
 /// <summary>
 /// Increase the score of the given Player.
 /// </summary>
 /// <param name="player">the player whose score to increase</param>
 private void Score(PlayerType player) => this.scores[player].Increment();
Ejemplo n.º 33
0
 public void SetMode(PlayerType type)
 {
     m_Type = type;
 }
Ejemplo n.º 34
0
 public Bishop(int _x, int _y, PlayerType pt, FigureType ft, Engine e) : base(_x, _y, pt, ft, e)
 {
 }
Ejemplo n.º 35
0
 {   /// <summary>
     /// create CaoCao
     /// </summary>
     /// <param name="pos"> this is the position of the player in All player</param>
     public CaoCao(int pos, PlayerType type) : base(pos, Legends_of_the_Three_Kingdoms.Properties.Resources.Cao_Cao, Legends_of_the_Three_Kingdoms.Properties.Resources.When_Cao_Cao_is_damaged_by_a_c, 4, type)
     {
     }
Ejemplo n.º 36
0
        private int Search(Game game, PlayerType player, int alpha, int beta, int depth, List <MoveCommand> bestMoveCommands, CancellationToken cancellation)
        {
            if (cancellation.IsCancellationRequested)
            {
                return(0);
            }

            if (game.State.IsEnd)
            {
                if (game.State.GameResult.Winner == player)
                {
                    return(InfiniteEvaluationValue);
                }
                else
                {
                    return(-InfiniteEvaluationValue);
                }
            }

            //if (game.IsWinning(player.Opponent))
            //    return -InfiniteEvaluationValue;
            //if (game.IsWinning(player))
            //    return InfiniteEvaluationValue;

            if (depth <= 0)              // [深さが最大に達した]
            {
                return(Evaluation(game, player));
            }

            var moveCommands = game.CreateAvailableMoveCommand();

            if (debug)
            {
                if (depth == this.Depth)
                {
                    System.Diagnostics.Debug.WriteLine("------------------------------------");
                    System.Diagnostics.Debug.WriteLine("深さ:" + depth.ToString());
                    System.Diagnostics.Debug.WriteLine("---------盤面------------");
                    System.Diagnostics.Debug.WriteLine(game.ToString());
                    System.Diagnostics.Debug.WriteLine("手番:" + game.State.TurnPlayer.ToString());
                    System.Diagnostics.Debug.WriteLine("---------着手可能手------------");
                    System.Diagnostics.Debug.WriteLine(string.Join('\n', moveCommands));
                }
            }

            if (moveCommands.Count == 0)
            {
                System.Diagnostics.Debug.WriteLine("★着手可能手0");
                return(-InfiniteEvaluationValue);
            }

            // [αβ法は良い手の順に探索を行うと最も効率が良い]
            moveCommands = SortByBetterMove(moveCommands, game);

            // [★勝ち確のときに遊ぶのを何とかしたい]

            // [全ての子ノードを展開し,再帰的に評価]
            for (int i = 0; i < moveCommands.Count; i++)
            {
                var gameTmp = game.Clone().PlayWithoutCheck(moveCommands[i]);

                // [現在,既に自分は最低でもα値の手が存在するため,相手が相手にとって-α値より良い手を見つけても]
                // [無意味となるため(自分はその手を指さないだけ),-α値が相手の探索の上限となる.]

                // [MEMO:枝刈りした場合、最善手と同じ評価値を返しているのでα値と同じ値が返っても、]
                // [最善手ではないので注意(相手側がより最善の手があるので)]
                int val = -Search(gameTmp, player.Opponent, -beta, -alpha, depth - 1, null, cancellation);

                // [MEMO:キャンセルした場合は、候補手一覧は空にするため、ここでリターンする]
                if (cancellation.IsCancellationRequested)
                {
                    return(0);
                }

                // [最善手(MAX)を求める]
                if (alpha < val)
                {
                    alpha = val;                // [α値の更新]

                    if (bestMoveCommands != null)
                    {
                        bestMoveCommands.Clear();
                        bestMoveCommands.Add(moveCommands[i]);
                    }
                }

                if (debug)
                {
                    if (depth == this.Depth)
                    {
                        System.Diagnostics.Debug.WriteLine("評価値:" + moveCommands[i].ToString() + " -> " + val.ToString());
                    }
                }
                //System.Diagnostics.Debug.WriteLine((new string(' ', Depth- depth)) + "評価値:" + moveCommands[i].ToString() + " -> " + val.ToString()) ;


                if (alpha >= beta)       // [より良い手がないと枝切りを行う]
                {
                    return(alpha);
                }
            }
            return(alpha);
        }
Ejemplo n.º 37
0
    public Card getNextOfferedCard(PlayerType characterIn)
    {
        var card = RouletteSelection.pick(allCards.Where(c => characterIn == c.playerType && c.isStarting == false));

        return((Card)(Activator.CreateInstance(card.GetType())));
    }
Ejemplo n.º 38
0
    private void setPrefs()
    {
        //set gameMode, whiteplayer, and blackplayer variables based on input from character select screen
        int player1character = PlayerPrefs.GetInt("Player1Character");
        int player2character = PlayerPrefs.GetInt("Player2Character");

        int gameIndex = SceneManager.GetActiveScene().buildIndex;

        if (gameIndex == 6)
        {
            gameMode = PlayerType.Local;
            //set the player2 character
            player2character = PlayerPrefs.GetInt("Player2Character");
        }
        else if (gameIndex == 7)
        {
            gameMode = PlayerType.Network;
            //more in another function because need the game core by then
        }
        else if (gameIndex == 8)
        {
            gameMode = PlayerType.AI;
            //pick a random character for the AI
            int aiCharacter = Random.Range(0, 2);
            while (aiCharacter == player1character)
            {
                //so ai and player will not be same character
                aiCharacter = Random.Range(0, 2);
            }
            player2character = aiCharacter;

            if (PlayerPrefs.GetInt("difficulty", 0) == 1)
            {
                _isHardMode = true;
            }
            else
            {
                _isHardMode = false;
            }
        }

        int player1white = PlayerPrefs.GetInt("player1", 0);

        if (player1white == 0)
        {
            //player1 is white
            whitePlayer = PlayerType.Local;
            blackPlayer = gameMode;
            //blackCam.enabled = false;
            //Camera.main.enabled = true;
            SetNotations(true);
            whiteCharacter = player1character;
            blackCharacter = player2character;
            isPlayer1White = true;
        }
        else if (player1white != 0 && gameMode != PlayerType.Local)
        {
            //player1 is black
            blackPlayer         = PlayerType.Local;
            whitePlayer         = gameMode;
            blackCam.enabled    = true;
            Camera.main.enabled = false;
            SetNotations(false);
            blackCharacter = player1character;
            whiteCharacter = player2character;
            isPlayer1White = false;
        }

        //set the player portraits
        setCharacterImage(1, player1character);
        setCharacterImage(2, player2character);

        gameMode = whitePlayer;
        //testfirst();

        //set the tokens
        TokenSetter tokenScript = GetComponent <TokenSetter>();

        tokenScript.SetTokens(player1white, player1character, player2character);

        //set the character for the emotes
        player1emote.SetCharacter(player1character, true);
        player2emote.SetCharacter(player2character, false);

        //set the log's characters
        log.SetCharacters(whiteCharacter, blackCharacter);
    }
Ejemplo n.º 39
0
 public Koma FindHandKoma(PlayerType player, KomaType komaType)
 {
     return(KomaList.FirstOrDefault(x => x.Player == player && x.IsInHand && x.KomaType == komaType));
 }
Ejemplo n.º 40
0
 public BoardPositions BoardPositions(PlayerType player)
 {
     return(new BoardPositions(KomaList.Where(x => x.Player == player && x.IsOnBoard).Select(x => x.BoardPosition).ToList()));
 }
Ejemplo n.º 41
0
 public bool IsTurnPlayer(PlayerType player)
 {
     return(TurnPlayer == player);
 }
Ejemplo n.º 42
0
 public List <Koma> GetKomaListDistinct(PlayerType player)
 {
     return(GetKomaList(player).Distinct(new Koma.ValueComparer()).ToList());
 }
Ejemplo n.º 43
0
 public GameState(List <Koma> komaList, PlayerType turnPlayer)
 {
     KomaList   = komaList;
     TurnPlayer = turnPlayer;
     GameResult = null;
 }
Ejemplo n.º 44
0
 {/// <summary>
  /// create SunQuan
  /// </summary>
  /// <param name="pos ">is the position of the player in All player</param>
     public SunQuan(int pos, PlayerType type) : base(pos, Legends_of_the_Three_Kingdoms.Properties.Resources.Sun_Quan, Legends_of_the_Three_Kingdoms.Properties.Resources.Once_during_his_turn_Sun_Quan_, 4, type)
     {
     }
Ejemplo n.º 45
0
        /// <summary>
        /// 打牌
        /// </summary>
        /// <param name="seatIdx">出牌玩家座号</param>
        /// <param name="paiIdx">牌号</param>
        /// <param name="paiType">牌类型(已有手牌还是摸过来的牌)</param>
        /// <param name="mjFaceValue">牌面值</param>
        /// <param name="handActionNum">手部动作编号</param>
        public void DaPai(int seatIdx, PlayerType handStyle,
                          int paiIdx, HandPaiType paiType, MahjongFaceValue mjFaceValue,
                          bool isJiaoTing,
                          ActionCombineNum handActionNum,
                          LinkedListNode <MahjongMachineCmd> opCmdNode = null)
        {
            StopSelectPaiActionState(seatIdx);

            if (playerStateData[seatIdx].playerHandActionState != HandActionState.ACTION_END ||
                mjSeatHandPaiLists[seatIdx].Count == 0 || mjSeatHandPaiLists[seatIdx][0] == null)
            {
                RemoveHandActionOpCmd(seatIdx, opCmdNode);
                return;
            }

            if (paiIdx >= 0 &&
                ((paiIdx < mjSeatHandPaiLists[seatIdx].Count && paiType == HandPaiType.HandPai) ||
                 (paiIdx < mjSeatMoPaiLists[seatIdx].Count && paiType == HandPaiType.MoPai)))
            {
                if (paiType == HandPaiType.HandPai)
                {
                    if (paiIdx >= mjSeatHandPaiLists[seatIdx].Count)
                    {
                        RemoveHandActionOpCmd(seatIdx, opCmdNode);
                        return;
                    }

                    GameObject mj = mjSeatHandPaiLists[seatIdx][paiIdx];

                    if (mj == null)
                    {
                        RemoveHandActionOpCmd(seatIdx, opCmdNode);
                        return;
                    }

                    mjSeatHandPaiLists[seatIdx].RemoveAt(paiIdx);

                    if (seatIdx != 0)
                    {
                        mjAssetsMgr.PushMjToOtherHandMjPool(mj);
                    }
                    else
                    {
                        mjAssetsMgr.PushMjToDeskOrSelfHandMjPool(mj);
                    }
                }
                else
                {
                    if (paiIdx >= mjSeatMoPaiLists[seatIdx].Count)
                    {
                        RemoveHandActionOpCmd(seatIdx, opCmdNode);
                        return;
                    }

                    GameObject mj = mjSeatMoPaiLists[seatIdx][paiIdx];

                    if (mj == null)
                    {
                        RemoveHandActionOpCmd(seatIdx, opCmdNode);
                        return;
                    }

                    mjSeatMoPaiLists[seatIdx].RemoveAt(paiIdx);

                    if (seatIdx != 0)
                    {
                        mjAssetsMgr.PushMjToOtherHandMjPool(mj);
                    }
                    else
                    {
                        mjAssetsMgr.PushMjToDeskOrSelfHandMjPool(mj);
                    }
                }
            }

            NextDeskMjPos(seatIdx);
            Vector3Int mjposIdx = GetCurtDeskMjPosIdx(seatIdx);

            playerStateData[seatIdx].SetDaPaiData(handStyle, mjposIdx, mjFaceValue, isJiaoTing, handActionNum, opCmdNode);
            playerStateData[seatIdx].SetPlayerState(HandActionState.DA_PAI_START, Time.time, -1);
        }
Ejemplo n.º 46
0
 {/// <summary>
  /// create ZhangFei
  /// </summary>
  /// <param name="pos ">this is the position of the player in All player</param>
     public ZhangFei(int pos, PlayerType type) :  base(pos, Legends_of_the_Three_Kingdoms.Properties.Resources.Zhang_Fei, Legends_of_the_Three_Kingdoms.Properties.Resources.Zhang_Fei_has_no_restrictions_, 4, type)
     {
     }
Ejemplo n.º 47
0
 public void Init(PlayerType yourStartPosition, GameConstraints gameConstraints)
 {
     startPosition = yourStartPosition;
 }
Ejemplo n.º 48
0
 {   /// <summary>
     /// Create Lumeng
     /// </summary>
     /// <param name="pos">this is the position of the player in All player</param>
     public LuMeng(int pos, PlayerType type) : base(pos, Legends_of_the_Three_Kingdoms.Properties.Resources.Lu_Meng, Legends_of_the_Three_Kingdoms.Properties.Resources.If_Lu_Meng_does_not_use_any_At, 4, type)
     {
     }
Ejemplo n.º 49
0
 /// <summary>
 /// parameterized constructor uses an existing id to create another player object
 /// </summary>
 /// <param name="id">int</param>
 public Player(int id, PlayerType type)
 {
     ID     = id;
     m_Type = type;
 }
Ejemplo n.º 50
0
 /// <summary>
 /// create LiuBei
 /// </summary>
 /// <param name="pos"> this is the position of the player in All player</param>
 public LiuBei(int pos, PlayerType type) : base(pos, Legends_of_the_Three_Kingdoms.Properties.Resources.Liu_Bei, Legends_of_the_Three_Kingdoms.Properties.Resources.Liu_Bei_s_can_give_any_number_, 4, type)
 {
 }
Ejemplo n.º 51
0
        public void CreateAHumanPlayer(Type expectedType, PlayerType playerType)
        {
            var player = _playerFactory.Create(playerType, "Player 1");

            Assert.IsType(expectedType, player);
        }
Ejemplo n.º 52
0
        public void FillList(int amount, List <Control> controls, List <Control> allControls, PlayerType playerType, Panel board, Random random)
        {
            for (int i = 0; i < amount; i++)
            {
                Control newPlayer = new PictureBox()
                {
                    Location = new Point(random.Next(20, 230), random.Next(20, 230)),
                    Height   = 10,
                    Width    = 10
                };

                switch (playerType)
                {
                case PlayerType.Human:
                    newPlayer.BackColor = Color.Blue;
                    break;

                case PlayerType.Soldier:
                    newPlayer.BackColor = Color.DarkGreen;
                    break;

                case PlayerType.Zombie:
                    newPlayer.BackColor = Color.Red;
                    break;
                }

                controls.Add(newPlayer);
                allControls.Add(newPlayer);
                board.Controls.Add(newPlayer);
            }
        }
Ejemplo n.º 53
0
        public Boolean CheckWinner(PointIndex point, PlayerType state)
        {
            if (point == null)
            {
                throw new ArgumentNullException(nameof(point));
            }

            for (Int32 x = 0; x < this.BoardSize; x++)
            {
                if (this.Board[x, point.Y] != state)
                {
                    break;
                }

                if (x == this.BoardSize - 1)
                {
                    this.GetWinnerMessage(state);
                    this.WinnerState = true;
                    return(true);
                }
            }

            for (Int32 y = 0; y < this.BoardSize; y++)
            {
                if (this.Board[point.X, y] != state)
                {
                    break;
                }

                if (y == this.BoardSize - 1)
                {
                    this.GetWinnerMessage(state);
                    this.WinnerState = true;
                    return(true);
                }
            }

            for (Int32 x = 0, y = 0; x < this.BoardSize && y < this.BoardSize; x++, y++)
            {
                if (this.Board[x, y] != state)
                {
                    break;
                }

                if (x == this.BoardSize - 1 || y == this.BoardSize - 1)
                {
                    this.GetWinnerMessage(state);
                    this.WinnerState = true;
                    return(true);
                }
            }

            for (Int32 x = this.BoardSize - 1, y = 0; x >= 0 && y < this.BoardSize; x--, y++)
            {
                if (this.Board[x, y] != state)
                {
                    break;
                }

                if (x == 0 || y == this.BoardSize - 1)
                {
                    this.GetWinnerMessage(state);
                    this.WinnerState = true;
                    return(true);
                }
            }

            this.CurrentTurnCount++;
            if (this.CurrentTurnCount == this.BoardSize * this.BoardSize)
            {
                this.GetWinnerMessage(state);
                this.WinnerState = true;
                return(true);
            }

            this.CurrentTurn = this.CurrentTurn == PlayerType.X ? PlayerType.O : PlayerType.X;
            return(false);
        }
Ejemplo n.º 54
0
 public List <Koma> GetBoardKomaList(PlayerType player)
 {
     return(KomaList.Where(x => x.Player == player && x.IsOnBoard).ToList());
 }
Ejemplo n.º 55
0
    private static void ControlRod(PlayerType Player, FieldModel Field, RodModel Rod, Command Decision)
    {
        Anticipate Anticipated = Field.Ball.getRowIntersection(Rod.Column);
        int        Coeff       = Player == PlayerType.Host ? 1 : -1;

        if (Anticipated.Row == -1)
        {
            if (Rod.Position == RodPosition.Top)
            {
                Decision.MoveDown(Rod.Type);
            }
            else if (Rod.Position == RodPosition.Bottom)
            {
                Decision.MoveUp(Rod.Type);
            }
            else
            {
                Decision.NoAction(Rod.Type);
            }
            return;
        }

        if (!Rod.RowInPlayerReach(Anticipated.Row))
        {
            // move to AnticipateDefend.Row
            if (Rod.Position == RodPosition.Middle && Anticipated.Row >= 6)
            {
                Decision.MoveDown(Rod.Type);
            }
            else if (Rod.Position == RodPosition.Middle)
            {
                Decision.MoveUp(Rod.Type);
            }
            else if (Rod.Position == RodPosition.Top)
            {
                Decision.MoveDown(Rod.Type);
            }
            else
            {
                Decision.MoveUp(Rod.Type);
            }
            return;
        }

        if (!Anticipated.Near)
        {
            Decision.NoAction(Rod.Type);
            return;
        }

        //Check here
        // Here the ball is in reach and the rod is in position and ready to shoot
        if (Anticipated.Column == (-1 * Coeff) && !(Player == PlayerType.Guest && Field.Ball.Column == 5))
        {
            Decision.Kick(Rod.Type, DIRECTION.FORWARD, 1);
            return;
        }

        if (Anticipated.Column == 0)
        {
            Decision.Kick(Rod.Type, getKickDirection(Player, Anticipated.Row, 1), 1);
        }

        if (Anticipated.Column == (1 * Coeff))
        {
            if (Rod.Type == RodType.Defense)
            {
                Decision.Kick(Rod.Type, getKickDirection(Player, Anticipated.Row, 5), 5);
            }
            else
            {
                Decision.Kick(Rod.Type, getGoalDirection(Player, Anticipated.Row), 5);
            }
        }
    }
Ejemplo n.º 56
0
 public Koma FindKingOnBoard(PlayerType player)
 {
     // [MEMO:プレイヤーの王は盤上に1つのみあることを前提]
     return(KomaList.FirstOrDefault(x => x.Player == player && x.KomaType.IsKing && x.IsOnBoard));
 }
        private bool IsDestinationValid(int fromColumn, int toColumn, PieceType toPieceType, PlayerType playerInTurn)
        {
            switch (playerInTurn)
            {
            case PlayerType.Black:
                if (fromColumn != toColumn && toPieceType != PieceType.Black)
                {
                    return(true);
                }
                if (fromColumn == toColumn && toPieceType == PieceType.None)
                {
                    return(true);
                }
                break;

            case PlayerType.White:
                if (fromColumn != toColumn && toPieceType != PieceType.White)
                {
                    return(true);
                }
                if (fromColumn == toColumn && toPieceType == PieceType.None)
                {
                    return(true);
                }
                break;
            }
            return(false);
        }
Ejemplo n.º 58
0
 public GameState(List <Koma> komaList, PlayerType turnPlayer, GameResult gameResult)
 {
     KomaList   = komaList;
     TurnPlayer = turnPlayer;
     GameResult = gameResult;
 }
Ejemplo n.º 59
0
    private void ChangeTurn()
    {
        isWhiteTurn = !isWhiteTurn;
        if (isWhiteTurn)
        {
            if (isPlayer1White)
            {
                turnText.text = player1 + "'s Turn";
                AnimateAvatars(1);
            }
            else
            {
                turnText.text = player2 + "'s Turn";
                AnimateAvatars(2);
            }

            if (whitePlayer == PlayerType.AI)
            {
                gameMode = PlayerType.AI;
                GetMove();
            }
            else if (whitePlayer == PlayerType.Network)
            {
                gameMode = PlayerType.Network;
                GetMove();
            }
            else if (whitePlayer == PlayerType.Local && blackPlayer == PlayerType.Local)
            {
                //enable white's emote button
                GameObject player1 = GameObject.FindGameObjectWithTag("Player1");
                Button     emote   = player1.transform.GetChild(3).GetChild(2).gameObject.GetComponent <Button>();
                emote.interactable = true;

                //disable black's emote button
                GameObject player2 = GameObject.FindGameObjectWithTag("Player2");
                Button     emote2  = player2.transform.GetChild(3).GetChild(2).gameObject.GetComponent <Button>();
                emote2.interactable = false;
            }
            //play a sound for the character
            //PlayTurnChangeSoundEffect(whiteCharacter);
        }
        else if (isBlackTurn)
        {
            if (!isPlayer1White)
            {
                turnText.text = player1 + "'s Turn";
                AnimateAvatars(1);
            }
            else
            {
                turnText.text = player2 + "'s Turn";
                AnimateAvatars(2);
            }
            if (blackPlayer == PlayerType.AI)
            {
                gameMode = PlayerType.AI;
                GetMove();
            }
            else if (blackPlayer == PlayerType.Network)
            {
                gameMode = PlayerType.Network;
                GetMove();
            }
            else if (whitePlayer == PlayerType.Local && blackPlayer == PlayerType.Local)
            {
                //disable white's emote button
                GameObject player1 = GameObject.FindGameObjectWithTag("Player1");
                Button     emote   = player1.transform.GetChild(3).GetChild(2).gameObject.GetComponent <Button>();
                emote.interactable = false;

                //enable blacks's emote button
                GameObject player2 = GameObject.FindGameObjectWithTag("Player2");
                Button     emote2  = player2.transform.GetChild(3).GetChild(2).gameObject.GetComponent <Button>();
                emote2.interactable = true;
            }
            //play a sound for the character
            //PlayTurnChangeSoundEffect(blackCharacter);
        }
    }
Ejemplo n.º 60
0
 public List <Koma> GetKomaList(PlayerType player)
 {
     return(KomaList.Where(x => x.Player == player).ToList());
 }