コード例 #1
1
ファイル: Human.cs プロジェクト: VoronFX/SummerPractice
        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);
        }
コード例 #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);
 }
コード例 #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;
        }
    }
コード例 #4
0
ファイル: Program.cs プロジェクト: LightRay2/ContestFramework
            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);
            }
コード例 #5
0
ファイル: Program.cs プロジェクト: LightRay2/ContestFramework
            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));
                }
            }
コード例 #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();
        }
コード例 #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);
        }
コード例 #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;
    }
コード例 #9
0
    public bool IsEnemy( PlayerSide otherPlayerSide )
    {
        if( IsBlank() )
            return false;

        return piece.IsEnemy( otherPlayerSide );
    }
コード例 #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();
        }
    }
コード例 #11
0
 private void OnTurnBegin(PlayerSide player)
 {
     foreach (Troop troop in troopMap.GetTroops(player))
     {
         troop.ResetMovePoints();
     }
 }
コード例 #12
0
ファイル: Battle.cs プロジェクト: Mathijsthunder3/PokemonGen1
        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;
        }
コード例 #13
0
 public static void ProcessCellsBySide(this CachedField gameField, PlayerSide side, Action <int> processor)
 {
     foreach (var cellIdx in gameField.PiecesBySide(side))
     {
         processor(cellIdx);
     }
 }
コード例 #14
0
ファイル: ChessPiece.cs プロジェクト: chichikov/chichikov76
 public ChessPiece()
 {
     gameObject = null;
     playerSide = PlayerSide.e_NoneSide;
     pieceType = PieceType.e_None;
     piecePlayerType = PiecePlayerType.eNone_Piece;
 }
コード例 #15
0
 private static void PlayerControlsTroop(PlayerSide player, Troop troop)
 {
     if (player != troop.Player)
     {
         throw new IllegalMoveException("Attempting to move enemy troop!");
     }
 }
コード例 #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;
        }
コード例 #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;
        }
コード例 #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);
         }
     }
 }
コード例 #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));
        }
    }
コード例 #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();
    }
コード例 #21
0
ファイル: Player.cs プロジェクト: Megazorn/Lanepeons
 public Player(string name, PlayerSide side)
 {
     Id = index;
     index++;
     Name = name;
     Side = side;
 }
コード例 #22
0
        protected override void ResetGame()
        {
            left  = new BlockFallInstance(this, serverRnd, true);
            right = new BlockFallInstance(this, clientRnd, false);

            PlayerSide.Reset();
        }
コード例 #23
0
 private void IsPlayersTurn(PlayerSide player)
 {
     if (player != activePlayer)
     {
         throw new IllegalMoveException("Attempting to make a move in opponent's turn!");
     }
 }
コード例 #24
0
ファイル: ChessPiece.cs プロジェクト: chichikov/chichikov76
 public void SetPiece( ChessPiece chessPiece )
 {
     this.gameObject = chessPiece.gameObject;
     this.playerSide = chessPiece.playerSide;
     this.pieceType = chessPiece.pieceType;
     this.piecePlayerType = chessPiece.piecePlayerType;
 }
コード例 #25
0
ファイル: ChangeUI.cs プロジェクト: hilfor/HitAndHide
 public void ChangeUi(PlayerSide playerSide)
 {
     foreach (IChangeableUI changeableComponent in changeableComponentsObjects)
     {
         changeableComponent.ChangeUi(playerSide);
     }
 }
コード例 #26
0
 public bool HaveGold(PlayerSide playerSide, int ammount)
 {
     if (_players[playerSide].Gold >= ammount)
     {
         return(true);
     }
     return(false);
 }
コード例 #27
0
ファイル: ChessPiece.cs プロジェクト: chichikov/chichikov
 public ChessPiece()
 {
     gameObject = null;
     playerSide = PlayerSide.e_NoneSide;
     pieceType = PieceType.e_None;
     piecePlayerType = PiecePlayerType.eNone_Piece;
     bEnPassantCapture = false;
 }
コード例 #28
0
 public void InitHandler(PlayerSide side, BaseMovement otherPlayer)
 {
     handler            = Instantiate(handlerPrefab);
     handler.playerMcts = this;
     handler.opponent   = otherPlayer;
     handler.side       = side;
     handler.InitAwake();
 }
コード例 #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;
     }
 }
コード例 #30
0
ファイル: ChessPiece.cs プロジェクト: chichikov/chichikov76
    public ChessPiece( GameObject gameObject, PlayerSide playerSide, 
		PiecePlayerType piecePlayerType )
    {
        this.gameObject = gameObject;
        this.playerSide = playerSide;
        this.pieceType = ChessUtility.GetPieceType( piecePlayerType );
        this.piecePlayerType = piecePlayerType;
    }
コード例 #31
0
 public void NewGame()
 {
     ResetBoard();
     selectedPawn   = Rectangle.Empty;
     selectedCol    = -1;
     selectedRow    = -1;
     previousPlayer = PlayerSide.BLACK;
 }
コード例 #32
0
ファイル: ChessPiece.cs プロジェクト: chichikov/chichikov
 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;
 }
コード例 #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;
 }
コード例 #34
0
ファイル: Troop.cs プロジェクト: AleksanderMisztal/GameServer
 public Troop(PlayerSide player, int movePoints, VectorTwo position, int orientation, int health)
 {
     Player            = player;
     InitialMovePoints = movePoints;
     MovePoints        = movePoints;
     Position          = position;
     Orientation       = orientation;
     Health            = health;
 }
コード例 #35
0
 public bool GetGold(PlayerSide playerSide, int ammount)
 {
     if (HaveGold(playerSide, ammount))
     {
         _players[playerSide].Gold -= ammount;
         return(true);
     }
     return(false);
 }
コード例 #36
0
 public Player(PlayerSide _side, ChoiceHandler _choiceHandler, Game _game)
 {
     game              = _game;
     Side              = _side;
     ChoiceHandler     = _choiceHandler;
     SummationDeck     = new SummationDeckHolder();
     Hand              = new HandHolder();
     PerformedMulligan = false;
 }
コード例 #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>();
 }
コード例 #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;
 }
コード例 #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);
    }
コード例 #40
0
ファイル: Player.cs プロジェクト: fiftin/Pengball
 public Player(string id, PengWorld world, PlayerSide side, Vector2 startPosition)
     : base(id, world)
 {
     Side = side;
     StartPosition = startPosition;
     JumpImpulse = DefaultJumpImpulse;
     Velocity = DefaultVelocity;
     ListenContacts = true;
     Initialize();
 }
コード例 #41
0
ファイル: Ball.cs プロジェクト: fiftin/Pengball
        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();
        }
コード例 #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);
        }
    }
コード例 #43
0
ファイル: ComputerPlayer.cs プロジェクト: fiftin/Pengball
 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;
 }
コード例 #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;
 }
コード例 #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);
    }
コード例 #46
0
ファイル: ManualPlayer.cs プロジェクト: fiftin/Pengball
 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;
     }
 }
コード例 #47
0
ファイル: ChessBoard.cs プロジェクト: chichikov/chichikov76
    // 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();
    }
コード例 #48
0
ファイル: ChessBoard.cs プロジェクト: chichikov/chichikov76
    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 );
    }
コード例 #49
0
ファイル: ChessPiece.cs プロジェクト: chichikov/chichikov76
 public bool IsEnemy( PlayerSide otherPlayerSide )
 {
     if( IsBlank() == false && playerSide != otherPlayerSide )
         return true;
     return false;
 }
コード例 #50
0
ファイル: ChessBoard.cs プロジェクト: chichikov/chichikov
    // 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();
    }
コード例 #51
0
ファイル: ChessData.cs プロジェクト: chichikov/chichikov76
    // get oppsite Side
    public static PlayerSide GetOppositeSide( PlayerSide side )
    {
        if( side == PlayerSide.e_White )
            return PlayerSide.e_Black;

        return PlayerSide.e_White;
    }
コード例 #52
0
ファイル: PlayerMonitor.cs プロジェクト: hilfor/HitAndHide
 public void SetPlayerSide(PlayerSide playerSide)
 {
     this.playerSide = playerSide;
     changeUIComponent.ChangeUi(playerSide);
 }