// If locationToCompare is "ahead" or equal rank of locationBase, return true, else false // "Ahead" being defined as closer to relative end of board while being in same file public bool IsAhead(Vector2 locationBase, Vector2 locationToCompare, PlayerColor playerColor) { return(locationBase == locationToCompare || (locationBase.x == locationToCompare.x && (DirectionService.CalcDirection(playerColor) == Direction.UP ? locationBase.y <= locationToCompare.y : locationBase.y >= locationToCompare.y))); }
public void CreatePiece( PlayerColor playerOwner, PieceType front, PieceType back, PieceSide side, int fileNum, int rankNum) { var piece = prefabsDictionary.Instantiate("Piece"); var pieceImpl = piece.GetComponent <PieceImpl>(); var pieceLocationMoveImpl = piece.GetComponent <PieceLocationMoveImpl>(); var pieceHighlightOwnerImpl = piece.GetComponent <PieceHighlightOwnerImpl>(); entityFactory.BuildEntity <PieceED>(piece.GetInstanceID(), piece.GetComponents <IImplementor>()); pieceImpl.Front = front; pieceImpl.Back = back; pieceImpl.PieceType = side == PieceSide.FRONT ? front : back; pieceImpl.Direction = DirectionService.CalcDirection(playerOwner); pieceHighlightOwnerImpl.PlayerColor = playerOwner; Vector2 location = CommonService.CalcTransformPosition(fileNum, rankNum); piece.transform.position = new Vector3(location.x, location.y, 1); pieceLocationMoveImpl.Location = new Vector2(fileNum, rankNum); pieceHighlightOwnerImpl.PlayChangeColor = true; }
public void SetPiecePlayerOwner(PieceEV pieceEV, PlayerColor playerOwner, IEntitiesDB entitiesDB) { Direction newDirection = DirectionService.CalcDirection(playerOwner); entitiesDB.ExecuteOnEntity( pieceEV.ID, (ref PieceEV pieceToChange) => { pieceToChange.PlayerOwner.PlayerColor = playerOwner; pieceToChange.Piece.Direction = newDirection; }); }