Exemplo n.º 1
1
        public Human(Game game, SpriteBatch screenSpriteBatch,
            PlayerSide playerSide)
            : base(game, screenSpriteBatch)
        {
            string idleTextureName = "";
            this.playerSide = playerSide;

            if (playerSide == PlayerSide.Left)
            {
                catapultPosition = new Vector2(140, 332);
                idleTextureName = "Textures/Catapults/Blue/blueIdle/blueIdle";
            }
            else
            {
                catapultPosition = new Vector2(600, 332);
                spriteEffect = SpriteEffects.FlipHorizontally;
                idleTextureName = "Textures/Catapults/Red/redIdle/redIdle";
            }

            Catapult = new Catapult(game, screenSpriteBatch,
                                    idleTextureName, catapultPosition,
                                    spriteEffect,
                                    playerSide == PlayerSide.Left
                                        ? false : true, true);
        }
Exemplo n.º 2
0
 public DefenderExample(Team team, ICoach coach, PlayerSide side)
     : base(team, coach)
 {
     m_startPosition = new PointF(m_sideFactor * 30, 0);
     m_PlayerSide    = side;
     m_PosOfLastKick = new PointF(-100, -100);
 }
Exemplo n.º 3
0
    void UpdateStateMobileSimulate()
    {
        if (Input.GetMouseButtonDown(0))
        {
            PlayerSide side     = PlayerSide.None;
            Vector2    position = Input.mousePosition;

            if (position.x < (Screen.width / 2) && position.y > (Screen.height / 2))
            {
                side = PlayerSide.Front;
            }
            if (position.x > (Screen.width / 2) && position.y > (Screen.height / 2))
            {
                side = PlayerSide.Right;
            }
            if (position.x < (Screen.width / 2) && position.y < (Screen.height / 2))
            {
                side = PlayerSide.Back;
            }
            if (position.x > (Screen.width / 2) && position.y < (Screen.height / 2))
            {
                side = PlayerSide.Left;
            }

            if (m_state == State.Idle)
            {
                MoveMobile(side);
            }

            m_camerasScript.SetWinEvent(side, 10);
            m_isAIActive = false;
        }
    }
Exemplo n.º 4
0
            public double Estimate(PlayerSide side)
            {
                double r = 0.0;

                double badness = 0.0;
                var    fr      = EnumFriends(side);

                foreach (var f in fr)
                {
                    badness += Math.Abs(f.X - 9) + Math.Abs(f.Y - 9);
                    if (f.X > 5 && f.Y > 5)
                    {
                        badness -= 5.0;
                    }
                }

                r -= badness;

                if (fr.Select((_) => _.X < 6 && _.Y < 6).Count() == 0)
                {
                    r += 10000.0;
                }

                return(r);
            }
Exemplo n.º 5
0
            public IEnumerable <Step> EnumerateSteps(PlayerSide side)
            {
                var t = EnumFriends(side);

                foreach (var tl in t)
                {
                    if (tl.X + 1 < 10 && this[tl.Add(1, 0)] == TileState.None)
                    {
                        yield return(new Step(tl, tl.Add(1, 0)));
                    }
                    if (tl.Y + 1 < 10 && this[tl.Add(0, 1)] == TileState.None)
                    {
                        yield return(new Step(tl, tl.Add(0, 1)));
                    }
                    //if (x.X + 1 < 10 && x.Y + 1 < 10 && this[x.Add(1, 1)] == TileState.None)
                    //    yield return new Step(x, x.Add(1, 1));

                    if (tl.X - 1 >= 0 && this[tl.Add(-1, 0)] == TileState.None)
                    {
                        yield return(new Step(tl, tl.Add(-1, 0)));
                    }
                    if (tl.Y - 1 >= 0 && this[tl.Add(0, -1)] == TileState.None)
                    {
                        yield return(new Step(tl, tl.Add(0, -1)));
                    }

                    foreach (var v in EnumJumps(tl, tl, 0, new HashSet <Point>()))
                    {
                        yield return(v);
                    }
                    //if (x.X - 1 >= 0 && x.Y - 1 >= 0 && this[x.Add(-1, -1)] == TileState.None)
                    //    yield return new Step(x, x.Add(-1, -1));
                }
            }
Exemplo n.º 6
0
        public void ProcessMove(PlayerSide player, VectorTwo position, int direction)
        {
            if (!validator.IsLegalMove(player, position, direction))
            {
                return;
            }
            Troop troop = troopMap.Get(position);

            MoveTroop(position, direction);
            if (!board.IsInside(troop.Position))
            {
                ControlWithAi(troop);
            }

            while (!GameHasEnded())
            {
                if (movePointsLeft == 0)
                {
                    ToggleActivePlayer();
                }
                else
                {
                    return;
                }
            }
            OnGameEnded();
        }
Exemplo n.º 7
0
        protected override void OnOpen()
        {
            using var db = Program.Services.GetRequiredService <ChessDbContext>();
            try
            {
                if (!Handler.findToken(Context.CookieCollection[AuthToken.SessionToken].Value, out var bUser, out _))
                {
                    Context.WebSocket.Close(CloseStatusCode.Normal, "Authentication failed.");
                    return;
                }
                Player = db.Players.FirstOrDefault(x => x.DiscordAccount == ChessService.cast(bUser.Id));
            } catch
            {
                Context.WebSocket.Close(CloseStatusCode.Normal, "Forbidden - must authenticate.");
                return;
            }
            var id = Guid.Parse(Context.QueryString.Get("id"));

            if (ChessService.TimedGames.TryGetValue(id, out var g))
            {
                Game = g;
                Game.ListeningWS.Add(this);
            }
            if (Game.White.Id == Player.Id)
            {
                Changeable = PlayerSide.White;
            }
            else if (Game.Black.Id == Player.Id)
            {
                Changeable = PlayerSide.Black;
            }
            SendStatus(((DateTimeOffset)DateTime.UtcNow).ToUnixTimeSeconds(), true);
        }
Exemplo n.º 8
0
    /**
     * Returns true if game is over.
     */
    public bool AddPoint(PlayerSide side)
    {
        bool result = false;

        switch (side) {
            case PlayerSide.Left:
                scoreRight++;
                if (scoreRight >= pointsToWin) {
                    winTextRight.enabled = true;
                    result = true;
                    MaximumLevelManager.SaveMaxLevel(levelNumber);
                }
                break;

            case PlayerSide.Right:
                scoreLeft++;
                if (scoreLeft >= pointsToWin) {
                    winTextLeft.enabled = true;
                    result = true;
                }
                break;
            default:
                Debug.LogError("Side not specified!");
                break;
        }

        UpdateScores();

        if (result) {
            buttons.SetActive(true);
            UnityEngine.Cursor.visible = true;
        }

        return result;
    }
Exemplo n.º 9
0
    public bool IsEnemy( PlayerSide otherPlayerSide )
    {
        if( IsBlank() )
            return false;

        return piece.IsEnemy( otherPlayerSide );
    }
Exemplo n.º 10
0
    public void DeadUnit(CharMovement unit)
    {
        PlayerSide playerSide = unit.playerSide;

        string caption = captionsLibrary.GetCaption(CaptionsLibrary.CaptionsType.Death, playerSide);

        uiManager.CreateCaption(caption, unit.unitSpriteHandler.baseColor.transform);

        audioManager.PlaySoundEffect(audioLibrary.death[(int)playerSide]);

        switch (playerSide)
        {
        case PlayerSide.Cats:
            catObjects.Remove(unit);
            break;

        case PlayerSide.Dogs:
            dogObjects.Remove(unit);
            break;
        }

        Destroy(unit.hPBar.gameObject);
        unit.unitSpriteHandler.DeathAnimation(unit.gameObject);
        Destroy(unit);

        if (catObjects.Count <= 0 || dogObjects.Count <= 0)
        {
            EndGame();
        }
    }
 private void OnTurnBegin(PlayerSide player)
 {
     foreach (Troop troop in troopMap.GetTroops(player))
     {
         troop.ResetMovePoints();
     }
 }
Exemplo n.º 12
0
        private void ExecutionSetSelectionState()
        {
            Selection playerSelection;
            Selection opponentSelection;

            //check, for both players, if engaged in a two-turn move which will prevent choosing
            if (!PlayerSide.CurrentBattlePokemon.IsTwoTurnMoveActive())
            {
                playerSelection = PlayerActor.MakeBeginningOfTurnSelection(this, PlayerSide);
            }
            else
            {
                playerSelection = Selection.MakeFight(PlayerSide.CurrentBattlePokemon,
                                                      OpponentSide.CurrentBattlePokemon,
                                                      PlayerSide.CurrentBattlePokemon.GetTwoTurnMove());
            }
            if (!OpponentSide.CurrentBattlePokemon.IsTwoTurnMoveActive())
            {
                opponentSelection = OpponentActor.MakeBeginningOfTurnSelection(this, OpponentSide);
            }
            else
            {
                opponentSelection = Selection.MakeFight(OpponentSide.CurrentBattlePokemon,
                                                        PlayerSide.CurrentBattlePokemon,
                                                        OpponentSide.CurrentBattlePokemon.GetTwoTurnMove());
            }
            PlayerSide.SetSelection(playerSelection);
            OpponentSide.SetSelection(opponentSelection);
            State = BattleState.SetFirstAndSecond;
        }
Exemplo n.º 13
0
 public static void ProcessCellsBySide(this CachedField gameField, PlayerSide side, Action <int> processor)
 {
     foreach (var cellIdx in gameField.PiecesBySide(side))
     {
         processor(cellIdx);
     }
 }
Exemplo n.º 14
0
 public ChessPiece()
 {
     gameObject = null;
     playerSide = PlayerSide.e_NoneSide;
     pieceType = PieceType.e_None;
     piecePlayerType = PiecePlayerType.eNone_Piece;
 }
Exemplo n.º 15
0
 private static void PlayerControlsTroop(PlayerSide player, Troop troop)
 {
     if (player != troop.Player)
     {
         throw new IllegalMoveException("Attempting to move enemy troop!");
     }
 }
Exemplo n.º 16
0
        public GameBoard()
        {
            gameBoardImg       = new Bitmap(Xiangqi.Properties.Resources.smboard);
            gameBoardPositions = new IPawn[10, 9];

            pawnSizeWidth  = PawnBitmapCollection.WIDTH;
            pawnSizeHeight = PawnBitmapCollection.HEIGHT;

            spaceBetweenPawnsX = 12;
            spaceBetweenPawnsY = 12;

            imageType = 1;

            selectedPawn   = Rectangle.Empty;
            previousPlayer = PlayerSide.BLACK;

            PlacePawns();

            screenWidthMiddle = GameScreen.width / 2;
            int gameBoardWidthMiddle = gameBoardImg.Width / 2;

            screenWidthMiddle = screenWidthMiddle - gameBoardWidthMiddle;

            screenHeightMiddle = GameScreen.height / 2;
            int gameBoardHeighMiddle = gameBoardImg.Height / 2;

            screenHeightMiddle = screenHeightMiddle - gameBoardHeighMiddle;
        }
Exemplo n.º 17
0
        private void InitializeGame()
        {
            string   _settings = PlayerPrefs.GetString("Settings");
            Settings settings  = JsonUtility.FromJson <Settings>(_settings);

            boardSize = settings.size;

            player1Side = (settings.side == 0) ? PlayerSide.X : PlayerSide.O;
            gameType    = (settings.type == 0) ? GameType.AR : GameType.Simple;
            if (gameType == GameType.AR)
            {
                uiManager.arPanel.gameObject.SetActive(true);
                transform.SetParent(uiManager.arParent, true);
                transform.localScale = Vector3.one;
            }
            else
            {
                transform.SetParent(null, true);
                transform.localScale = Vector3.one;
                gameObject.SetActive(true);
            }

            gameMode = (settings.mode == 0) ? GameMode.SinglePlayer : GameMode.TwoPlayer;
            if (gameMode == GameMode.TwoPlayer)
            {
                ChangeTurn();
            }

            player2Side = (player1Side == PlayerSide.X) ? PlayerSide.O : PlayerSide.X; // if single player, player 2 is AI

            GameOver = false;
        }
Exemplo n.º 18
0
 public void Activate(PlayerSide side, GameMode mode)
 {
     if (side == PlayerSide.Player)
     {
         if (mode == GameMode.Tetrin)
         {
             PlayerTetoPerspective.gameObject.SetActive(true);
             PlayerBuyoPerspective.gameObject.SetActive(false);
         }
         if (mode == GameMode.BuyoBuyo)
         {
             PlayerBuyoPerspective.gameObject.SetActive(true);
             PlayerTetoPerspective.gameObject.SetActive(false);
         }
     }
     if (side == PlayerSide.Opponent)
     {
         if (mode == GameMode.Tetrin)
         {
             OpponentTetoPerspective.gameObject.SetActive(true);
             OpponentBuyoPerspective.gameObject.SetActive(false);
         }
         if (mode == GameMode.BuyoBuyo)
         {
             OpponentBuyoPerspective.gameObject.SetActive(true);
             OpponentTetoPerspective.gameObject.SetActive(false);
         }
     }
 }
Exemplo n.º 19
0
    public void PlayerPhaseTurn(EventHookPhase hookPhase, EventHookType type, PlayerSide CurrentAtker, RangeType range)
    {
        phaseTurn.PlayAnim(hookPhase, type);

        if (hookPhase == EventHookPhase.MoveCardDropPhase && type == EventHookType.Before)
        {
            StartCoroutine(SelfCCSetPhase.MovePhaseAnimation(true));
            return;
        }
        else if (hookPhase == EventHookPhase.MoveCardDropPhase && type == EventHookType.After)
        {
            StartCoroutine(SelfCCSetPhase.MovePhaseAnimation(false));
            return;
        }

        // self is atker
        if (CurrentAtker == PlayerSide.Host)
        {
            StartCoroutine(SelfCCSetPhase.AttackerPhaseAnimation(hookPhase, type, range));
            StartCoroutine(DuelCCSetPhase.DeferencePhaseAnimation(hookPhase, type, range));
        }
        else
        {
            // dueler is atker
            StartCoroutine(DuelCCSetPhase.AttackerPhaseAnimation(hookPhase, type, range));
            StartCoroutine(SelfCCSetPhase.DeferencePhaseAnimation(hookPhase, type, range));
        }
    }
Exemplo n.º 20
0
    // Use this for initialization
    void Start()
    {
        dialogCooldown = Random.Range(10, 15);
        hp             = totalHp;
        roamCountdown  = Random.Range(2, 5);
        agent          = GetComponent <NavMeshAgent>();
        childSprite    = gameObject.transform.GetChild(0);
        charSprite     = childSprite.GetComponent <SpriteRenderer>();
        unitSpriteHandler.Init();

        if (gameObject.tag == "Cat")
        {
            target     = GameObject.FindGameObjectsWithTag("CatPatrol");
            playerSide = PlayerSide.Cats;
            myHouse    = GameObject.Find("Player1");
        }
        else
        {
            target     = GameObject.FindGameObjectsWithTag("DogPatrol");
            playerSide = PlayerSide.Dogs;
            myHouse    = GameObject.Find("Player2");
        }

        numOfTargetPoints = target.Length;
        randomNumber      = Random.Range(0, numOfTargetPoints - 1);
        countUnit();
    }
Exemplo n.º 21
0
 public Player(string name, PlayerSide side)
 {
     Id = index;
     index++;
     Name = name;
     Side = side;
 }
Exemplo n.º 22
0
        protected override void ResetGame()
        {
            left  = new BlockFallInstance(this, serverRnd, true);
            right = new BlockFallInstance(this, clientRnd, false);

            PlayerSide.Reset();
        }
Exemplo n.º 23
0
 private void IsPlayersTurn(PlayerSide player)
 {
     if (player != activePlayer)
     {
         throw new IllegalMoveException("Attempting to make a move in opponent's turn!");
     }
 }
Exemplo n.º 24
0
 public void SetPiece( ChessPiece chessPiece )
 {
     this.gameObject = chessPiece.gameObject;
     this.playerSide = chessPiece.playerSide;
     this.pieceType = chessPiece.pieceType;
     this.piecePlayerType = chessPiece.piecePlayerType;
 }
Exemplo n.º 25
0
 public void ChangeUi(PlayerSide playerSide)
 {
     foreach (IChangeableUI changeableComponent in changeableComponentsObjects)
     {
         changeableComponent.ChangeUi(playerSide);
     }
 }
Exemplo n.º 26
0
 public bool HaveGold(PlayerSide playerSide, int ammount)
 {
     if (_players[playerSide].Gold >= ammount)
     {
         return(true);
     }
     return(false);
 }
Exemplo n.º 27
0
 public ChessPiece()
 {
     gameObject = null;
     playerSide = PlayerSide.e_NoneSide;
     pieceType = PieceType.e_None;
     piecePlayerType = PiecePlayerType.eNone_Piece;
     bEnPassantCapture = false;
 }
 public void InitHandler(PlayerSide side, BaseMovement otherPlayer)
 {
     handler            = Instantiate(handlerPrefab);
     handler.playerMcts = this;
     handler.opponent   = otherPlayer;
     handler.side       = side;
     handler.InitAwake();
 }
Exemplo n.º 29
0
 public void AddGold(PlayerSide playerSide, int ammount)
 {
     _players[playerSide].Gold += ammount;
     if (_players[playerSide].Gold >= _players[playerSide].GoldMax)
     {
         _players[playerSide].Gold = _players[playerSide].GoldMax;
     }
 }
Exemplo n.º 30
0
    public ChessPiece( GameObject gameObject, PlayerSide playerSide, 
		PiecePlayerType piecePlayerType )
    {
        this.gameObject = gameObject;
        this.playerSide = playerSide;
        this.pieceType = ChessUtility.GetPieceType( piecePlayerType );
        this.piecePlayerType = piecePlayerType;
    }
Exemplo n.º 31
0
 public void NewGame()
 {
     ResetBoard();
     selectedPawn   = Rectangle.Empty;
     selectedCol    = -1;
     selectedRow    = -1;
     previousPlayer = PlayerSide.BLACK;
 }
Exemplo n.º 32
0
 public void CopyFrom( ChessPiece chessPiece )
 {
     this.gameObject = chessPiece.gameObject;
     this.playerSide = chessPiece.playerSide;
     this.pieceType = chessPiece.pieceType;
     this.piecePlayerType = chessPiece.piecePlayerType;
     this.bEnPassantCapture = chessPiece.bEnPassantCapture;
 }
Exemplo n.º 33
0
 public S2C_InitNewGame(GameRuleSetBase gameRuleSet, PlayerDisplay opponent, PlayerSide side)
 {
     this.BoardSize             = gameRuleSet.BoardSize;
     this.Fleet                 = gameRuleSet.GetFleet();
     this.ContinueTurnUntilMiss = gameRuleSet.ContinueTurnUntilMiss;
     this.Opponent              = opponent;
     this.Side = side;
 }
Exemplo n.º 34
0
 public Troop(PlayerSide player, int movePoints, VectorTwo position, int orientation, int health)
 {
     Player            = player;
     InitialMovePoints = movePoints;
     MovePoints        = movePoints;
     Position          = position;
     Orientation       = orientation;
     Health            = health;
 }
Exemplo n.º 35
0
 public bool GetGold(PlayerSide playerSide, int ammount)
 {
     if (HaveGold(playerSide, ammount))
     {
         _players[playerSide].Gold -= ammount;
         return(true);
     }
     return(false);
 }
Exemplo n.º 36
0
 public Player(PlayerSide _side, ChoiceHandler _choiceHandler, Game _game)
 {
     game              = _game;
     Side              = _side;
     ChoiceHandler     = _choiceHandler;
     SummationDeck     = new SummationDeckHolder();
     Hand              = new HandHolder();
     PerformedMulligan = false;
 }
Exemplo n.º 37
0
 // Start is called before the first frame update
 void Start()
 {
     button1.GoldWastedEvent += Button1IsPressed;
     button2.GoldWastedEvent += Button2IsPressed;
     SpawnTime        = 0;
     _spawnInProgress = false;
     _playerSide      = gameObject.GetComponent <OwnerComponent>().Player;
     _gameManager     = FindObjectOfType <GameLoopManager>();
 }
Exemplo n.º 38
0
 internal RoundResults(PlayerSide roundWinner, CombatWinner combatWinner, PlayerStatus leftPlayerStatus, PlayerStatus rightPlayerStatus, RoundStatistics leftPlayerStatistics, RoundStatistics rightPlayerStatistics)
 {
     CombatWinner          = combatWinner;
     RoundWinner           = roundWinner;
     LeftPlayerStatus      = leftPlayerStatus;
     RightPlayerStatus     = rightPlayerStatus;
     LeftPlayerStatistics  = leftPlayerStatistics;
     RightPlayerStatistics = rightPlayerStatistics;
 }
Exemplo n.º 39
0
    public void HealerUnit(CharMovement unit)
    {
        PlayerSide playerSide = unit.playerSide;
        string     caption    = captionsLibrary.GetCaption(CaptionsLibrary.CaptionsType.Healer, playerSide);
        AudioClip  clip       = audioLibrary.RandomCaption(playerSide);

        audioManager.PlayVoiceLine(clip);
        uiManager.CreateCaption(caption, unit.unitSpriteHandler.baseColor.transform);
    }
Exemplo n.º 40
0
 public Player(string id, PengWorld world, PlayerSide side, Vector2 startPosition)
     : base(id, world)
 {
     Side = side;
     StartPosition = startPosition;
     JumpImpulse = DefaultJumpImpulse;
     Velocity = DefaultVelocity;
     ListenContacts = true;
     Initialize();
 }
Exemplo n.º 41
0
        public Ball(string name, PengWorld world, Vector2 leftStartPos, Vector2 rightStartPos, float radius, PlayerSide side)
            : base(name, world)
        {
            this.radius = radius;
            LeftStartPos = leftStartPos;
            RightStartPos = rightStartPos;
            InitialSide = side;

            Inititalize();
        }
Exemplo n.º 42
0
    public void AddPointAndSpawnNewBall(PlayerSide player)
    {
        bool gameOver = scoreManager.AddPoint(player);

        if (! gameOver) {
            ResetBall();
            KickBall(player == PlayerSide.Left ? PlayerSide.Right : PlayerSide.Left);
        } else {
            ball.gameObject.SetActive(false);
        }
    }
Exemplo n.º 43
0
 public ComputerPlayer(string id, PengWorld world, PlayerSide side, Vector2 startPosition)
     : base(id, world, side, startPosition)
 {
     string screenplay = ((PengballWorld)world).Screenplay;
     screenplay = screenplay.Replace("ComputerPlayer", "Player");
     parallelWorld = new PengballWorld(null, world.Content, false, screenplay, false);
     parallelWorld.Tag = "parallelWorld";
     ((PengballWorld)world).Loaded += new EventHandler(world_Loaded);
     TargetPositionOffset = 0.07f;
     TargetPositionRandomOffset = 0.05f;
 }
Exemplo n.º 44
0
 Vector3 getSpawnlocation(PlayerSide playerSide)
 {
     ArrayList playersSideSpawnPoints = new ArrayList();
     foreach (PlayerSpawnPoint spawnPoint in spawnPoints)
     {
         if (spawnPoint.spawnSide == playerSide)
         {
             playersSideSpawnPoints.Add(spawnPoint);
         }
     }
     int randomSpawnIndex = Mathf.FloorToInt(Random.Range(0f, playersSideSpawnPoints.Count - 1));
     return ((PlayerSpawnPoint)playersSideSpawnPoints[randomSpawnIndex]).transform.position;
 }
Exemplo n.º 45
0
    public void KickBall(PlayerSide targetSide)
    {
        Rigidbody ballRigidBody = ball.GetComponent<Rigidbody>();
        Vector3 force = new Vector3(startingBallSpeed, startingBallSpeed, 0);

        if (targetSide == PlayerSide.Left) {
            force = new Vector3(-force.x, force.y, force.z);
        }

        if (Random.value > 0.5) {
            force = new Vector3(force.x, -force.y, force.z);
        }

        ballRigidBody.AddForce(force, ForceMode.Impulse);
    }
Exemplo n.º 46
0
 public ManualPlayer(string id, PengWorld world, PlayerSide dir, Vector2 startPosition)
     : base(id, world, dir, startPosition)
 {
     if (dir == PlayerSide.Left)
     {
         UpKey = Keys.W;
         LeftKey = Keys.A;
         RightKey = Keys.D;
     }
     else
     {
         UpKey = Keys.Up;
         LeftKey = Keys.Left;
         RightKey = Keys.Right;
     }
 }
Exemplo n.º 47
0
    // interface
    public void Init( BattleChessMain chessMain, Transform[] aPieceRef, ParticleSystem selectPSystemRef, ParticleSystem movablePSystemRef )
    {
        battleChessMain = chessMain;

        // etc property
        CurrTurn = PlayerSide.e_White;
        UserPlayerSide = PlayerSide.e_White;
        ThinkingTime = 18000;
        nCurrHalfMove = 0;
        nCurrTotalMove = 0;

        Ready = false;

        IsWhiteCallCheck = false;
        IsBlackCallCheck = false;

        IsWhiteInCheckMate = false;
        IsBlackInCheckMate = false;

        // move
        currWhiteMove = new ChessMover.sMove();
        currBlackMove = new ChessMover.sMove();

        listWhiteMoveHistory = new List<ChessMover.sMove>();
        listBlackMoveHistory = new List<ChessMover.sMove>();

        listCurrMovable = new List<ChessMover.sMove>();

        listCapturedPiece = new List<ChessPiece>();

        // init board
        bitBoard.Init();
        bitBoardVirtual.Init();

        // piece list
        listAllPiece = new List<ChessPiece>();
        listLivePiece = new List<ChessPiece>();
        aBoardSquare = new ChessBoardSquare[ChessData.nNumPile,ChessData.nNumRank];

        ChessPiece currPiece = null;
        for( int i=0; i<ChessData.nNumPile; i++ ){
            for( int j=0; j<ChessData.nNumRank; j++ ){

                // movable square effect Particle System
                //ParticleSystem movablePiecePSystem = MonoBehaviour.Instantiate( movablePSystemRef.gameObject, Vector3.zero, Quaternion.identity ) as ParticleSystem;
                ParticleSystem movablePiecePSystem = battleChessMain.gameObject.AddChildInstantiate<ParticleSystem>( movablePSystemRef, Vector3.zero, Quaternion.identity );

                if( ChessData.aStartPiecePos[i,j] == PiecePlayerType.eNone_Piece ) {

                    aBoardSquare[i,j] = new ChessBoardSquare( null, movablePiecePSystem, i, j );
                }
                else
                {
                    Vector3 currPos = new Vector3( j - 3.5f, 0.0f, i - 3.5f );

                    Transform currTransform = aPieceRef[(int)ChessData.aStartPiecePos[i,j]];
                    //Transform currPieceObject = MonoBehaviour.Instantiate( currTransform, currPos, currTransform.rotation ) as Transform;
                    Transform currPieceObject = battleChessMain.gameObject.AddChildInstantiate<Transform>( currTransform, currPos, currTransform.rotation );

                    if( i == 0 || i == 1 ) {

                        currPiece = new ChessPiece( currPieceObject.gameObject, PlayerSide.e_White,	ChessData.aStartPiecePos[i,j] );
                        listAllPiece.Add( currPiece );

                        aBoardSquare[i,j] = new ChessBoardSquare( currPiece, movablePiecePSystem, i, j );
                    }
                    else if( i == 6 || i == 7 ) {

                        currPiece = new ChessPiece( currPieceObject.gameObject, PlayerSide.e_Black,	ChessData.aStartPiecePos[i,j] );
                        listAllPiece.Add( currPiece );

                        aBoardSquare[i,j] = new ChessBoardSquare( currPiece, movablePiecePSystem, i, j );
                    }
                }
            }
        }

        // piece coloar
        SetWhiteSidePieceColor( Color.white );
        SetBlackSidePieceColor( Color.white );

        // board material
        if( chessMain.renderer.materials.Length == 2 ) {

            matBoard1 = chessMain.renderer.materials[0];
            matBoard2 = chessMain.renderer.materials[1];

            Color rgbaWhiteBoard, rgbaBlackBoard;
            rgbaWhiteBoard = new Color( 1.0f, 1.0f, 1.0f, 1.0f );
            rgbaBlackBoard = new Color( 0.039f, 0.34f, 0.22f, 1.0f );

            SetWhiteSideBoardColor( rgbaWhiteBoard );
            SetBlackSideBoardColor( rgbaBlackBoard );
        }

        // particle effect
        currSelectedSquare = null;
        //selectPiecePSystem = MonoBehaviour.Instantiate( selectPSystemRef, Vector3.zero, Quaternion.identity ) as ParticleSystem;
        selectPiecePSystem = battleChessMain.gameObject.AddChildInstantiate<ParticleSystem>( selectPSystemRef, Vector3.zero, Quaternion.identity );
        selectPiecePSystem.Stop();
    }
Exemplo n.º 48
0
    public void Restart()
    {
        // etc property
        CurrTurn = PlayerSide.e_White;
        UserPlayerSide = PlayerSide.e_White;
        ThinkingTime = 18000;
        nCurrHalfMove = 0;
        nCurrTotalMove = 0;

        Ready = true;

        IsWhiteCallCheck = false;
        IsBlackCallCheck = false;

        IsWhiteInCheckMate = false;
        IsBlackInCheckMate = false;

        // move
        currWhiteMove.Clear();
        currBlackMove.Clear();

        listWhiteMoveHistory.Clear();
        listBlackMoveHistory.Clear();

        listCurrMovable.Clear();

        listCapturedPiece.Clear();

        // init board
        bitBoard.Reset();
        bitBoardVirtual.Reset();

        // piece list
        listLivePiece.Clear();

        ChessPiece currPiece = null;
        for( int i=0; i<ChessData.nNumPile; i++ ){
            for( int j=0; j<ChessData.nNumRank; j++ ){

                if( ChessData.aStartPiecePos[i,j] == PiecePlayerType.eNone_Piece ) {

                    aBoardSquare[i,j].ClearPiece();
                }
                else
                {
                    if( i == 0 || i == 1 || i == 6 || i == 7 ) {

                        currPiece = listAllPiece.Find( piece => piece.piecePlayerType == ChessData.aStartPiecePos[i,j] );
                        if( currPiece != null ) {

                            listLivePiece.Add( currPiece );

                            aBoardSquare[i,j].ClearPiece();
                            aBoardSquare[i,j].SetPiece( currPiece );
                        }
                        else {

                            UnityEngine.Debug.LogError( "ChessBoard::Restart() - listAllPiece.Find() Error");
                        }
                    }
                }
            }
        }

        // particle effect
        SelectSquare( null );
    }
Exemplo n.º 49
0
 public bool IsEnemy( PlayerSide otherPlayerSide )
 {
     if( IsBlank() == false && playerSide != otherPlayerSide )
         return true;
     return false;
 }
Exemplo n.º 50
0
    // interface
    public void Init( BattleChessMain chessMain, Transform[] aPieceRef, ParticleSystem selectPSystemRef, ParticleSystem movablePSystemRef )
    {
        // etc property
        CurrTurn = PlayerSide.e_White;
        UserPlayerSide = PlayerSide.e_White;
        ThinkingTime = 18000;
        nCurrHalfMove = 0;
        nCurrTotalMove = 0;

        Ready = false;

        // move
        currMove = new ChessMoveManager.sMove();
        currCastlingState = new ChessCastling() {

            CastlingWKSide = CastlingState.eCastling_Enable_State,
            CastlingWQSide = CastlingState.eCastling_Enable_State,
            CastlingBKSide = CastlingState.eCastling_Enable_State,
            CastlingBQSide = CastlingState.eCastling_Enable_State
        };

        listCurrMovable = new List<ChessMoveManager.sMove>();

        // init board
        // piece list
        listPiece = new List<ChessPiece>();
        aBoardSquare = new ChessBoardSquare[ChessData.nNumPile,ChessData.nNumRank];

        ChessPiece currPiece = null;
        for( int i=0; i<ChessData.nNumPile; i++ ){
            for( int j=0; j<ChessData.nNumRank; j++ ){

                // movable square effect Particle System
                ParticleSystem movablePiecePSystem = MonoBehaviour.Instantiate( movablePSystemRef, Vector3.zero, Quaternion.identity ) as ParticleSystem;

                if( ChessData.aStartPiecePos[i,j] == PiecePlayerType.eNone_Piece ) {

                    aBoardSquare[i,j] = new ChessBoardSquare( null, movablePiecePSystem, i, j );
                }
                else
                {
                    Vector3 currPos = new Vector3( j - 3.5f, 0.0f, i - 3.5f );

                    Transform currTransform = aPieceRef[(int)ChessData.aStartPiecePos[i,j]];
                    Transform currPieceObject = MonoBehaviour.Instantiate( currTransform, currPos, currTransform.rotation ) as Transform;

                    if( i == 0 || i == 1 ) {

                        currPiece = new ChessPiece( currPieceObject.gameObject, PlayerSide.e_White,	ChessData.aStartPiecePos[i,j] );
                        listPiece.Add( currPiece );

                        aBoardSquare[i,j] = new ChessBoardSquare( currPiece, movablePiecePSystem, i, j );
                    }
                    else if( i == 6 || i == 7 ) {

                        currPiece = new ChessPiece( currPieceObject.gameObject, PlayerSide.e_Black,	ChessData.aStartPiecePos[i,j] );
                        listPiece.Add( currPiece );

                        aBoardSquare[i,j] = new ChessBoardSquare( currPiece, movablePiecePSystem, i, j );
                    }
                }
            }
        }

        // piece coloar
        SetWhiteSidePieceColor( Color.white );
        SetBlackSidePieceColor( Color.white );

        // board material
        if( chessMain.renderer.materials.Length == 2 ) {

            matBoard1 = chessMain.renderer.materials[0];
            matBoard2 = chessMain.renderer.materials[1];

            Color rgbaWhiteBoard, rgbaBlackBoard;
            rgbaWhiteBoard = new Color( 1.0f, 1.0f, 1.0f, 1.0f );
            rgbaBlackBoard = new Color( 0.039f, 0.34f, 0.22f, 1.0f );

            SetWhiteSideBoardColor( rgbaWhiteBoard );
            SetBlackSideBoardColor( rgbaBlackBoard );
        }

        // particle effect
        selectSquare = null;
        selectPiecePSystem = MonoBehaviour.Instantiate( selectPSystemRef, Vector3.zero, Quaternion.identity ) as ParticleSystem;
        selectPiecePSystem.Stop();
    }
Exemplo n.º 51
0
    // get oppsite Side
    public static PlayerSide GetOppositeSide( PlayerSide side )
    {
        if( side == PlayerSide.e_White )
            return PlayerSide.e_Black;

        return PlayerSide.e_White;
    }
Exemplo n.º 52
0
 public void SetPlayerSide(PlayerSide playerSide)
 {
     this.playerSide = playerSide;
     changeUIComponent.ChangeUi(playerSide);
 }