Exemple #1
0
 public void SelectSquare(SquareType color)
 {
     _Tool          = Tool.Build;
     SelectedSquare = color;
     DestroyBuildSquare();
     _BuildSquare = SpawnBuildSquare();
 }
Exemple #2
0
        private void RevealOpponent(string squareType, SquareImage pawn)
        {
            string     path;
            SquareType type = (SquareType)Enum.Parse(typeof(SquareType), squareType, true);

            switch (type)
            {
            case SquareType.Paper:
                path = ImageFactory.BLUE_PAPER;
                break;

            case SquareType.Rock:
                path = ImageFactory.BLUE_ROCK;
                break;

            case SquareType.Scissors:
                path = ImageFactory.BLUE_SCISSORS;
                break;

            default:
                throw new Exception("invalid type");
            }

            _context.Dispatcher.Invoke(() => pawn.Image.Source = ImageFactory.LoadImage(path));
            pawn.Square.Type = type;
        }
        /// <summary>
        /// Creates a square painter for requested square type.
        /// </summary>
        /// <param name="squareType">The type of square to create a painter for.</param>
        /// <returns>The requested square painter if supported, otherwise null.</returns>
        public static SquarePainter CreateSquarePainter(SquareType squareType)
        {
            switch (squareType)
            {
                case SquareType.Empty:
                case SquareType.Unknown:
                    return new EmptySquarePainter();
                case SquareType.WaterSourceDown:
                    return new WaterSourceDownPainter();
                case SquareType.WaterSourceUp:
                    return new WaterSourceUpPainter();
                case SquareType.WaterSourceLeft:
                    return new WaterSourceLeftPainter();
                case SquareType.WaterSourceRight:
                    return new WaterSourceRightPainter();
                case SquareType.StraightHorizontal:
                    return new StraightHorizontalPipePainter();
                case SquareType.StraightVertical:
                    return new StraightVerticalPipePainter();
                case SquareType.EdgeDownLeft:
                    return new EdgeDownLeftPipePainter();
                case SquareType.EdgeUpLeft:
                    return new EdgeUpLeftPipePainter();
                case SquareType.EdgeDownRight:
                    return new EdgeDownRightPipePainter();
                case SquareType.EdgeUpRight:
                    return new EdgeUpRightPipePainter();
            }

            return null;
        }
Exemple #4
0
    public SquareType GetSquareType(int pIdSquareType)
    {
        SquareType s = new SquareType();

        string        conn = "URI=file:" + Application.streamingAssetsPath + "/AdvScrabble.db";  //Path to database.
        IDbConnection dbconn;

        dbconn = (IDbConnection) new SqliteConnection(conn);
        dbconn.Open();         //Open connection to the database.
        IDbCommand dbcmd    = dbconn.CreateCommand();
        string     sqlQuery = String.Format("SELECT * FROM square_type where id_square_type = \"{0}\"", pIdSquareType);

        dbcmd.CommandText = sqlQuery;
        IDataReader reader = dbcmd.ExecuteReader();

        while (reader.Read())
        {
            s.Id_type_square = reader.GetInt32(0);
            s.Name           = reader.GetString(1);
            s.Description    = reader.GetString(2);
        }
        dbcmd.Dispose();
        dbcmd = null;
        dbconn.Close();
        dbconn = null;

        return(s);
    }
 public Square(int row, int col)
 {
     // Row = row;
     // Col = col;
     Coordinates = new Coordinates(row, col);
     SquareType  = SquareType.Empty;
 }
Exemple #6
0
 // Resets square to default state
 public void Reset()
 {
     type   = SquareType.Empty;
     color  = new Color(0, 0, 0);
     sprite = null;
     connectedSquares.Clear();
 }
Exemple #7
0
    public void RemoveBlock()
    {
        int topLayer = blockObjects.Count - 1;

        if (topLayer >= 0)
        {
            //Animation
            blockObjects[topLayer].GetComponent <Animation>().Play("BrickRotate");
            blockObjects[topLayer].GetComponent <UISprite>().depth = 4;
            //Make it drop and rotate random
            blockObjects[topLayer].GetComponent <Rigidbody>().useGravity = true;
            blockObjects[topLayer].GetComponent <Rigidbody>().AddRelativeForce(Random.insideUnitCircle.x * Random.Range(30, 40), Random.Range(100, 150), 0);
            //Destroy and remove from list
            GameObject.Destroy(blockObjects[topLayer], 1.5f);
            blockObjects.RemoveAt(topLayer);

            //Reduce square style
            if (type == SquareType.block)
            {
                type = SquareType.normal;
                //Calculate score
                MissionManager.Instance.AddScore(1, MissionType.Block);
            }
            else if (type == SquareType.block_glass)
            {
                type = SquareType.block;
            }
            else if (type == SquareType.block_stone)
            {
                type = SquareType.block;
            }
        }
    }
Exemple #8
0
 //Init square by row, col and square type
 public Square(int pRow, int pCol, SquareType pType)
 {
     row          = pRow;
     col          = pCol;
     type         = pType;
     blockObjects = new List <GameObject>();
 }
    public bool DestinationOneAboveCurrent(SquareType currentPlayerSquareType, SquareType jumpToSquareType)
    {
        int heightCurrentSquare     = TileTypeHeight[(int)currentPlayerSquareType];
        int heightDestinationSquare = TileTypeHeight[(int)jumpToSquareType];

        return(heightDestinationSquare == heightCurrentSquare + 1 || heightDestinationSquare == heightCurrentSquare - 1);
    }
Exemple #10
0
 public Square(SquareType type, Vector3 squareSize, float positionx, float positiony)
 {
     this.type       = type;
     this.squareSize = squareSize;
     this.positionx  = positionx;
     this.positiony  = positiony;
 }
    public string MyToString()
    {
        string output = "";
        string charForCurrentType;

        for (int r = 0; r < mapSize; r++)
        {
            for (int c = 0; c < mapSize; c++)
            {
                SquareType currentSquareType = map[r, c];
                charForCurrentType = GetTypeToChar(currentSquareType);
                if (r == playerX)
                {
                    if (c == playerY)
                    {
                        charForCurrentType = GetTypeToCharPlayer(currentPlayerSquareType);
                    }
                }
                output += charForCurrentType + " ";
            }
            output += "\n";
        }
        output += "\n";
        output += "     Player at (" + playerX + ", " + playerY + ")";
        output += "\n last acction success = " + lastActionSuccess;
        return(output);
    }
Exemple #12
0
        /*
         * Renders the board by drawing the tetromino and
         * the board.
         */
        private void RenderBoard()
        {
            // draw the board
            for (int x = 0; x < WindowWidth; ++x)
            {
                for (int y = 0; y < WindowHeight; ++y)
                {
                    RenderedBoard[x, y] = Board.GetSquare(x, y);
                }
            }
            // put tetromino on top of it
            int       tx = Board.TetrominoX;
            int       ty = Board.TetrominoY;
            Tetromino t  = Board.FallingTetromino;

            if (t == null)
            {
                return;
            }

            for (int x = 0; x < Tetromino.TETROMINO_WIDTH; ++x)
            {
                for (int y = 0; y < Tetromino.TETROMINO_WIDTH; ++y)
                {
                    SquareType square = t.GetSquare(x, y);
                    if (square != SquareType.EMPTY)
                    {
                        RenderedBoard[x + tx, y + ty] = t.GetSquare(x, y);
                    }
                }
            }
        }
Exemple #13
0
 public Square(int x, int y, SquareType t)
 {
     this.col  = x;
     this.row  = y;
     Visited   = false;
     this.type = t;
 }
Exemple #14
0
 private void SetSquareTypes(SquareType t, Coord[] locs)
 {
     foreach (Coord loc in locs)
     {
         this.board[(int)loc.row, (int)loc.col].SquareType = t;
     }
 }
        public void MainMethod()
        {
            board = new TicTacToeBoard();
            Console.WriteLine("Hello! To play tic tac toe, when it is your turn, enter the index of where you want to play (0-8)");
            Console.Read();

            while (!board.IsFull() && !board.IsWinner(SquareType.X) && !board.IsWinner(SquareType.O))
            {
                DisplayBoardGrid();

                Console.WriteLine("It is {0} turn.", currentTurn);
                int move = promptForInt("Enter your index: ");
                if (board.IsLegalMove(move))
                    board.MakeMove(move, currentTurn);
                else
                {
                    Console.WriteLine("Illegal Move! Press enter!");
                    Console.Read();
                    continue;
                }
                // Swap the turn
                currentTurn = currentTurn == SquareType.X ? SquareType.O : SquareType.X;
            }

            DisplayBoardGrid();

            if (board.IsFull())
                Console.WriteLine("Tie! Board is full!");
            else if (board.IsWinner(SquareType.X))
                AccounceWinner(SquareType.X);
            else if (board.IsWinner(SquareType.O))
                AccounceWinner(SquareType.O);
            else
                Console.WriteLine("Something has gone wrong!");
        }
Exemple #16
0
 public Square(SquareType squareType, string name, int price, int rent)
 {
     Name  = name;
     Price = price;
     Rent  = rent;
     Type  = squareType;
 }
        internal static ImageSource LoadBlueImage(SquareType type)
        {
            string path;

            switch (type)
            {
            case SquareType.Flag:
                path = BLUE_FLAG;
                break;

            case SquareType.Trap:
                path = BLUE_TRAP;
                break;

            case SquareType.Rock:
                path = BLUE_ROCK;
                break;

            case SquareType.Paper:
                path = BLUE_PAPER;
                break;

            case SquareType.Scissors:
                path = BLUE_SCISSORS;
                break;

            default: throw new ArgumentException("invalid type");
            }
            return(LoadImage(path));
        }
Exemple #18
0
    /// <summary>
    /// Attachs the square component of given type to the game object.
    /// </summary>
    private Square AttachSquare(SquareType color, GameObject square)
    {
        switch (color)
        {
        case SquareType.Green:
            return(square.AddComponent <GreenSquare>());

        case SquareType.White:
            return(square.AddComponent <WhiteSquare>());

        case SquareType.Blue:
            return(square.AddComponent <BlueSquare>());

        case SquareType.Yellow:
            return(square.AddComponent <YellowSquare>());

        case SquareType.Purple:
            var purple = square.AddComponent <PurpleSquare>();
            purple.Particles = SpawnBoostParticles(purple.gameObject.transform,
                                                   SquareType.Purple);
            return(purple);

        case SquareType.Red:
            var red = square.AddComponent <RedSquare>();
            red.Particles = SpawnFireParticles(red.gameObject.transform);
            return(red);

        case SquareType.Black:
            return(square.AddComponent <BlackSquare>());

        default:
            throw new UnityException(message: "Square type not found.");
        }
    }
Exemple #19
0
 public Cell(SquareType type, int xCoord, int yCoord, bool visited)
 {
     this.type    = type;
     this.xCoord  = xCoord;
     this.yCoord  = yCoord;
     this.visited = visited;
 }
Exemple #20
0
        public object Convert(object value, Type targetType,
                              object parameter, CultureInfo culture)
        {
            SquareType type = (SquareType)value;

            switch (type)
            {
            case SquareType.Unknown:
                return(new SolidColorBrush(Colors.LightGray));

            case SquareType.Water:
                return(new SolidColorBrush(Colors.LightBlue));

            case SquareType.Undamaged:
                return(new SolidColorBrush(Colors.Black));

            case SquareType.Damaged:
                return(new SolidColorBrush(Colors.Orange));

            case SquareType.Sunk:
                return(new SolidColorBrush(Colors.Red));
            }

            throw new Exception("fail");
        }
Exemple #21
0
 public SquareRandom(SquareType type, Dictionary <Color, int> colorWeights, int seed = 0)
 {
     this.Type        = type;
     this.Random      = new Random(seed);
     this.ColorRandom = new WeightRandom <Color>(colorWeights);
     this.ColorRandom.InitRandom(Random.Next());
 }
    public bool CheckIfSameLevel(SquareType currentPlayerSquareType, SquareType moveToSquareType)
    {
        int currentTile = WalkableSquareTypes[(int)currentPlayerSquareType];
        int moveToTile  = WalkableSquareTypes[(int)moveToSquareType];

        return(currentTile == moveToTile);
    }
Exemple #23
0
    public void consumeMoves(int moveCost, SquareType squareType)
    {
        movesRemaining -= moveCost;
        Debug.Log(moveCost + " move(s) used, " + movesRemaining + " remaining");

        if ((squareType == SquareType.Rosette) && (hasAlreadyRerolled == false))
        {
            //Allow reroll
            Debug.Log("Landed on a rosette, allow re-roll");
            uiRollDice.gameObject.SetActive(true);
            uiSkipTurn.gameObject.SetActive(false);
            hasAlreadyRerolled = true;
            canRoll            = true;
        }
        else
        {
            if (movesRemaining <= 0)
            {
                togglePlayer();
            }
            else
            {
                Debug.Log("Player " + currentPlayer + " still has " + movesRemaining + " moves left.");
            }
        }
    }
Exemple #24
0
        private List <Square> GetAdjacentCrossSquares(int X, int Y, SquareType Type)
        {
            List <Square> squares = new List <Square>();

            if (Y > 0)
            {
                if (board[X][Y - 1].type == Type)
                {
                    squares.Add(board[X][Y - 1]);
                }
            }
            if (X > 0)
            {
                if (board[X - 1][Y].type == Type)
                {
                    squares.Add(board[X - 1][Y]);
                }
            }
            if (X < width - 1)
            {
                if (board[X + 1][Y].type == Type)
                {
                    squares.Add(board[X + 1][Y]);
                }
            }
            if (Y < height - 1)
            {
                if (board[X][Y + 1].type == Type)
                {
                    squares.Add(board[X][Y + 1]);
                }
            }

            return(squares);
        }
Exemple #25
0
        private void SquareTopicDataAvailable(ShapeTypeDataReader dr)
        {
            List <ShapeType>  samples = new List <ShapeType>();
            List <SampleInfo> infos   = new List <SampleInfo>();
            ReturnCode        error   = dr.Take(samples, infos);

            if (error == ReturnCode.Ok)
            {
                for (int i = 0; i < samples.Count; i++)
                {
                    SampleInfo info   = infos[i];
                    ShapeType  sample = samples[i];
                    if (info.ValidData)
                    {
                        int        x      = Convert.ToInt32((sample.x - (sample.shapesize / 2)) * _factorX);
                        int        y      = Convert.ToInt32((sample.y - (sample.shapesize / 2)) * _factorY);
                        SquareType square = new SquareType
                        {
                            Color             = sample.color,
                            X                 = x,
                            Y                 = y,
                            Size              = sample.shapesize,
                            PublicationHandle = info.PublicationHandle
                        };

                        SquareUpdated?.Invoke(this, square);
                    }
                }
            }
        }
        public BotletMove GetMoveToClosest(SquareType squareType)
        {
            var closest = ClosestOfType(squareType);
            var order   = GetMoveTo(closest);

            return(order);
        }
Exemple #27
0
 /// <summary>
 /// Applies definition to square.
 /// </summary>
 /// <param name="definition">The square definition to apply from.</param>
 public void FromDefinition(SquareDefinition definition)
 {
     /* check if supported */
     if (this.SupportsDefinition(definition))
     {
         this.Type = definition.Type;
     }
 }
Exemple #28
0
 public Ship(ShipDirection direction, SquareType shipType)
 {
     ShipName   = shipType.ToString();
     Direction  = direction;
     SquareType = shipType;
     IsSunk     = false;
     Size       = ShipSize();
 }
Exemple #29
0
        // Sets square at index to given values
        private void SetSquare(int index, SquareType type, Color color, Sprite sprite)
        {
            Square square = squares[index];

            square.type   = type;
            square.color  = color;
            square.sprite = sprite;
        }
Exemple #30
0
    public Bullet SpawnBullet(Vector3 position, Vector3 force, SquareType color)
    {
        var bulletObject = Instantiate(BulletPrefab, position, Quaternion.identity);

        bulletObject.GetComponent <Rigidbody>().AddForce(force);
        bulletObject.GetComponent <SpriteRenderer>().color = Game.GetColor(color);
        return(bulletObject.AddComponent <Bullet>());
    }
Exemple #31
0
 public Square(SquareType Type, int id, Color clr, SquareState State, bool FinishSquare)
 {
     this.SqState      = State;
     this.SqType       = Type;
     this.SqId         = id;
     this.SqClr        = clr;
     this.FinishSquare = FinishSquare;
     this.occupiedBy   = new List <Token>();
 }
 /// <summary>
 /// Creates a new instance of PresentSquareMapItemParameter class.
 /// </summary>
 /// <param name="id">The unique element id.</param>
 /// <param name="position">The position the item should be presented.</param>
 /// <param name="isActivated">The activation state of the item to present.</param>
 /// <param name="isFixed">The fixation state of the item to present.</param>
 /// <param name="squareId">The unique id of the square contained in item to present.</param>
 /// <param name="squareType">The square type contained in item to present.</param>
 public PresentSquareMapItemParameter(Guid id, Position position, bool isActivated, bool isFixed, Guid squareId, SquareType squareType)
     : base(id)
 {
     this.position = position;
     this.isActivated = isActivated;
     this.isFixed = isFixed;
     this.squareId = squareId;
     this.squareType = squareType;
 }
Exemple #33
0
    private GameObject SpawnBoostParticles(Transform parent, SquareType color)
    {
        var particles = Instantiate(BoostParticlesPrefab,
                                    parent);
        var main = particles.GetComponent <ParticleSystem>().main;

        main.startColor = Game.GetColor(color);
        return(particles);
    }
Exemple #34
0
 private void Start()
 {
     UI.UpdateListeners(SelectSquare,
                        SetErase,
                        SetAssign);
     SetErase();
     SelectedSquare    = SquareType.Green;
     this.JointTargets = new List <Square>();
 }
 public bool IsWinner(SquareType squareType)
 {
     // Check horizontal
     for (int i = 0; i < NUM_SQUARES; i += 3)
         if (squares[i] == squareType && squares[i + 1] == squareType && squares[i + 2] == squareType)
             return true;
     // Check vertical
     for (int i = 0; i < 3; i++)
         if (squares[i] == squareType && squares[i + 3] == squareType && squares[i + 6] == squareType)
             return true;
     // Check diagonal
     if ((squares[0] == squareType && squares[4] == squareType && squares[8] == squareType) || (squares[2] == squareType && squares[4] == squareType && squares[6] == squareType))
         return true;
     // else
     return false;
 }
        public void AppendTranslatedSquare(List<Vector3> vBuf, List<int> iBuf, Vector3 trans, SquareType st)
        {
            List<Vector3> tempBuf = new List<Vector3>(9);
            List<int> tempiBuf = new List<int>(24);
            tempBuf.Add(new Vector3(0, 0, 0) + trans);
            tempBuf.Add(new Vector3(0, 0, 1) + trans);
            tempBuf.Add(new Vector3(0, 0, 2) + trans);
            tempBuf.Add(new Vector3(1, 0, 1) + trans);
            tempBuf.Add(new Vector3(2, 0, 2) + trans);
            tempiBuf.AddRange(new int[] { 0, 1, 3, 1, 2, 3 });

            if (st == SquareType.TopRight || st == SquareType.TopRow)
            {
                tempiBuf.AddRange(new int[] { 4, 3, 2 });
                if(st == SquareType.TopRow)
                {
                    tempBuf.Add(new Vector3(1, 0, 0) + trans);
                    tempBuf.Add(new Vector3(2, 0, 0) + trans);
                    tempBuf.Add(new Vector3(2, 0, 1) + trans);
                    tempiBuf.AddRange(new int[] { 0, 3, 5, 5, 3, 6, 6, 3, 7, 7, 3, 4 });
                }
            }
            else
            {
                tempBuf.Add(new Vector3(1, 0, 2) + trans);
                tempiBuf.AddRange(new int[] { 5, 3, 2, 3, 5, 4 });
                if (st == SquareType.Normal)
                {
                    tempBuf.Add(new Vector3(1, 0, 0) + trans);
                    tempBuf.Add(new Vector3(2, 0, 0) + trans);
                    tempBuf.Add(new Vector3(2, 0, 1) + trans);
                    tempiBuf.AddRange(new int[] { 0, 3, 6, 6, 3, 7, 7, 3, 8, 8, 3, 4 });
                }
            }

            MathExtensions.AppendVertices(vBuf, iBuf, tempBuf, tempiBuf);
        }
Exemple #37
0
        /// <summary>
        /// Creates square.
        /// </summary>
        /// <param name="type">The type of square to create.</param>
        /// <returns>Newly created square if possible, otherwise null.</returns>
        public ISquareElement CreateSquare(SquareType type)
        {
            switch (type)
            {
                case SquareType.Empty:
                    return this.CreateEmptySquare();
                case SquareType.EdgeDownLeft:
                    return this.CreateEdgePipe(EdgePipeOrientation.DownLeft);
                case SquareType.EdgeDownRight:
                    return this.CreateEdgePipe(EdgePipeOrientation.DownRight);
                case SquareType.EdgeUpLeft:
                    return this.CreateEdgePipe(EdgePipeOrientation.UpLeft);
                case SquareType.EdgeUpRight:
                    return this.CreateEdgePipe(EdgePipeOrientation.UpRight);
                case SquareType.StraightHorizontal:
                    return this.CreateStraightPipe(StraightPipeOrientation.Horizontal);
                case SquareType.StraightVertical:
                    return this.CreateStraightPipe(StraightPipeOrientation.Vertical);
                case SquareType.WaterSourceDown:
                    return this.CreateWaterSource(Direction.Down);
                case SquareType.WaterSourceLeft:
                    return this.CreateWaterSource(Direction.Left);
                case SquareType.WaterSourceRight:
                    return this.CreateWaterSource(Direction.Right);
                case SquareType.WaterSourceUp:
                    return this.CreateWaterSource(Direction.Up);
                default:
                    break;
            }

            return null;
        }
 public void Reset(SquareType type, SquareObject objectType)
 {
     ObjectType = objectType;
     Type = type;
     SquareIndex = -1;
 }
 /// <summary>
 /// Creates a new instance of PresentSquareParameter class.
 /// </summary>
 /// <param name="id">The unique element id.</param>
 /// <param name="type">The square type to present.</param>
 public PresentSquareParameter(Guid id, SquareType type)
     : base(id)
 {
     this.type = type;
 }
 public void AccounceWinner(SquareType squareType)
 {
     Console.WriteLine("\n\n");
     Console.WriteLine("The winner is: " + squareType);
 }
Exemple #41
0
        /// <summary>
        /// Calculates and returns achievement points for given pipe count and square type on this level.
        /// </summary>
        /// <param name="pipeCount">The count of pipes so far.</param>
        /// <param name="squareType">The type of square to get points for.</param>
        /// <returns>Calculated achievement points.</returns>
        public int GetAchievementPoints(int pipeCount, SquareType squareType)
        {
            int points = 0;

            if (!SquareType.Unknown.Equals(squareType))
            {
                int typeFactor = 0;

                switch (squareType)
                {
                    case SquareType.EdgeDownLeft:
                    case SquareType.EdgeDownRight:
                    case SquareType.EdgeUpLeft:
                    case SquareType.EdgeUpRight:
                        typeFactor = 3 * this.number;
                        break;
                    case SquareType.StraightHorizontal:
                    case SquareType.StraightVertical:
                        typeFactor = 2 * this.number;
                        break;
                    case SquareType.WaterSourceDown:
                    case SquareType.WaterSourceLeft:
                    case SquareType.WaterSourceRight:
                    case SquareType.WaterSourceUp:
                        typeFactor = 1 * this.number;
                        break;
                    default:
                        break;
                }

                points += typeFactor + (pipeCount * this.number);
            }

            return points;
        }
Exemple #42
0
 public Square(SquareType startType)
 {
     type = startType;
     ownerPlayer = 0;
 }
Exemple #43
0
 /// <summary>
 /// Creates a new instance of SquareDefinition class.
 /// </summary>
 /// <param name="type">The type of square.</param>
 public SquareDefinition(SquareType type)
 {
     this.type = type;
 }
        void SetBoardValue(int idx, SquareType type)
        {
			Debug.Assert(mBoard[idx] == SquareType.ST_UNKNOWN || mBoard[idx] == type); // make sure we haven't set this one yet, or we've calculated it's value to remain the same. Otherwise, there's a logic error somewhere
			//if ((mBoard[idx] == SquareType.ST_UNKNOWN || mBoard[idx] == type) == false)
			//	throw new Exception();
            mBoardHasChanged |= mBoard[idx] != type;
            mBoard[idx] = type;
        }
Exemple #45
0
 public void Reset(SquareType type)
 {
     Type = type;
     ShipIndex = -1;
 }
Exemple #46
0
        /// <summary>
        /// Changes sqaure this control is presenting.
        /// </summary>
        /// <param name="squareId">The unique id of the new square to present.</param>
        /// <param name="squareType">The square tyoe of the new square to present.</param>
        /// <param name="isHighlighted">Indicates whether new square should be highlighted or not.</param>
        public void ChangeSquare(Guid squareId, SquareType squareType, bool isHighlighted)
        {
            if ((!Guid.Empty.Equals(squareId)) && (!SquareType.Unknown.Equals(squareType)))
            {
                /* set highlight */
                this.isHighlighted = isHighlighted;

                /* take square identification values */
                this.squareId = squareId;
                this.squareType = squareType;

                /* update painter */
                this.squarePainter = SquarePainterFactory.CreateSquarePainter(this.squareType);

                /* signal square change (refreshes control, too) */
                this.OnSquareChanged();
            }
        }
 void SetBoardValue(int x, int y, SquareType type)
 {
     int i = GetIndex(x, y);
     SetBoardValue(i, type);
 }
Exemple #48
0
        //************************************************************
        //* Prints the object of a square on the screen              *
        //* Gets the object type and form where to start writing     *
        //* All coordinates are in the console coordinate system     *
        //* Returns nothing                                          *
        //************************************************************
        static void PrintSquareType(SquareType type, int consoleRow, int consoleCol)
        {
            switch (type)
            {
                case SquareType.Free:
                    {
                        for (int i = 0; i < 3; i++)
                        {
                            Console.SetCursorPosition(consoleCol, consoleRow);
                            Console.ForegroundColor = ConsoleColor.White;
                            Console.Write(nothing[i]);
                            consoleRow++;
                        }
                        break;
                    }
                case SquareType.Wall:
                    {
                        for (int i = 0; i < 3; i++)
                        {
                            Console.SetCursorPosition(consoleCol, consoleRow);
                            Console.ForegroundColor = ConsoleColor.DarkRed;
                            Console.Write(wall[i]);
                            consoleRow++;
                        }
                        break;
                    }
                case SquareType.Target:
                    {
                        for (int i = 0; i < 3; i++)
                        {
                            Console.SetCursorPosition(consoleCol, consoleRow);
                            Console.ForegroundColor = ConsoleColor.DarkGray;
                            Console.Write(target[i]);
                            consoleRow++;
                        }
                        break;
                    }

            }
        }
Exemple #49
0
 /// <summary>
 /// Returns the cost of a given WalkState, where Unwalkable = +inf.
 /// Must be >= 1, to preserve Manhatten Distance Heuristic
 /// </summary>
 /// <param name="w">The walkstate to measure the cost of.</param>
 /// <returns>Slippery = 1.0, TableDef = 2.0, Sandpaper = 3.0, HotSquare = 5.0, Unwalkable = pos inf</returns>
 public float costOfWalkState(SquareType w)
 {
     switch (w)
     {
         case SquareType.Slippery:
             return 1.0f;
         case SquareType.TableDef:
             return 2.0f;
         case SquareType.Sandpaper:
             return 7.0f; 
         case SquareType.Unwalkable:
             return float.PositiveInfinity;
     }
     return float.PositiveInfinity;
 }
Exemple #50
0
        /// <summary>
        /// Constructs a Node.
        /// </summary>
        /// <param name="floorImg">The image which the node will use to display itself if set to do so.</param>
        /// <param name="position">Where the node is positioned in world space.</param>
        /// <param name="gridPos">The node position in the graph space.</param>
        /// <param name="scale">The node's visible scale.</param>
        /// <param name="num">The node's internal number.</param>
        /// <param name="vis">Whether the node is visible or not. Default is false.</param>
        public Node(GameObject parent, Sprite floorImg, Vector2 position, IntVec2 gridPos, SquareType typeOfTerrain, float scale = 0.75f, int num = 0, bool vis = true)
        {
            pos = position;
            this.gridPos = gridPos;
            GameObject drawer = new GameObject("Node " + pos);
            drawer.isStatic = true;
            drawer.transform.parent = parent.transform;

            //set sprite back in z, so it draws beneath everything.
            drawer.transform.position = new Vector3(position.x, position.y, 1);

            spriteDraw = drawer.AddComponent<SpriteRenderer>();
            spriteDraw.sprite = floorImg;
            drawer.tag = gameTag;
            // Draw a little bigger than scale.
            spriteDraw.transform.localScale = new Vector2(scale * 1.35f, scale * 1.35f);

            // Draw with 50% alpha-white.
            //spriteDraw.color = defColor;
            //terrainType = randWalkState();
            terrainType = typeOfTerrain;
            edgePenalty = costOfWalkState(terrainType);
            resetColor();
            //spriteDraw.color = Random.ColorHSV(0.2f, 1.0f, 0.1f, 0.7f, 0.2f, 1.0f);

            CameFrom = null;
            number = num;

#if DEBUG_NODE_EDGES
            lineDraw = drawer.AddComponent<LineRenderer>();
            lineDraw.SetWidth(0.1f, 0.1f);
            lineDraw.SetVertexCount(maxEdges * 2 + 1);
            for (int i = 0; i < 17; i++)
                lineDraw.SetPosition(i, pos);
#endif

#if DEBUG_NODE_TEXT
            GameObject guiText = new GameObject("Debug text on Node " + pos);
            Vector2 guiPos = new Vector2(Camera.main.WorldToScreenPoint(pos).x / Camera.main.pixelWidth,
                                         Camera.main.WorldToScreenPoint(pos).y / Camera.main.pixelHeight);
            guiText.transform.position = guiPos;
            visNodeNum = guiText.AddComponent<GUIText>();
            visNodeNum.text = num.ToString();
            visNodeNum.anchor = TextAnchor.MiddleCenter;
#endif
            // Do not move this, everything must be defined before calling Visible.
            Visible = vis;
        }
Exemple #51
0
 public Square(SquareType startType)
 {
     type = startType;
 }
 public Square(SquareType type, BoardPosition boardPosition)
 {
     this._type = type;
     this._boardPosition = boardPosition;
 }
 public void MakeMove(int index, SquareType squareType)
 {
     squares[index] = squareType;
 }
 /// <summary>
 /// Creates a new instance of PresentPipeFloodParameter class.
 /// </summary>
 /// <param name="id">The unique element id.</param>
 /// <param name="type">The square type to present flooding.</param>
 /// <param name="floodDirection">The direction to present flooding.</param>
 /// <param name="floodDuration">The duration to present flooding.</param>
 public PresentPipeFloodParameter(Guid id, SquareType type, Direction floodDirection, TimeSpan floodDuration)
     : base(id, type)
 {
     this.floodDuration = floodDuration;
     this.floodDirection = floodDirection;
 }