예제 #1
0
        private Dictionary <string, OthelloPiece> SetIsColliderEnabled(Dictionary <string, OthelloPiece> othelloPieces)
        {
            var result = new Dictionary <string, OthelloPiece>();

            foreach (var piece in othelloPieces)
            {
                if (result.ContainsKey(piece.Key))
                {
                    continue;
                }
                else
                {
                    result.Add(piece.Key, piece.Value);

                    if (piece.Value.color != 0)
                    {
                        foreach (var adjPos in GetAdjcentPositions(piece.Value.position))
                        {
                            if (othelloPieces[adjPos].color == 0)
                            {
                                var temp = new OthelloPiece(othelloPieces[adjPos].position, othelloPieces[adjPos].color.ToString(), true.ToString());
                                if (result.ContainsKey(adjPos))
                                {
                                    continue;
                                }
                                result.Add(adjPos, temp);
                            }
                        }
                    }
                }
            }

            log.Debug(result.Count);
            return(result);
        }
예제 #2
0
 public bool ValueEquals(OthelloPiece piece)
 {
     if (this.position.Equals(piece.position) && this.color == piece.color && this.isColliderEnabled == piece.isColliderEnabled)
     {
         return(true);
     }
     return(false);
 }
예제 #3
0
        private Dictionary <string, OthelloPiece> StoreState(JsonCarrier data)
        {
            var result = new Dictionary <string, OthelloPiece>();

            foreach (var pieceState in data.PieacesState)
            {
                //log.Debug(pieceState);
                var index1 = pieceState.IndexOf("\t");
                var index2 = pieceState.IndexOf("\t", index1 + 1);

                var position          = pieceState.Substring(0, index1);
                var color             = pieceState.Substring(index1 + 1, (index2 - index1 - 1));
                var isColliderEnabled = pieceState.Substring(index2 + 1);

                var piece = new OthelloPiece(position, color, isColliderEnabled);
                result.Add(position, piece);
            }
            return(result);
        }
예제 #4
0
        public Dictionary <string, OthelloPiece> ChangeStateComp(string lastPosition, Dictionary <string, OthelloPiece> othelloPieces)
        {
            log.Info("Start ChangeStateComp " + lastPosition);
            var result = new Dictionary <string, OthelloPiece>();

            foreach (var piece in othelloPieces)
            {
                result.Add(piece.Key, new OthelloPiece(piece.Value.position, piece.Value.color.ToString(), piece.Value.isColliderEnabled.ToString()));
            }

            var adjPositions = GetAdjcentPositions(lastPosition);
            var compPosition = GetCompPosition(adjPositions, result);
            var compPiece    = new OthelloPiece(compPosition, "2", false.ToString());

            result.Remove(compPosition);
            result.Add(compPosition, compPiece);

            log.Info("End ChangeStateComp " + compPosition + " " + result[compPosition].color);
            return(result);
        }