예제 #1
0
 public void Initialize(PieceParameters parameters)
 {
     color = parameters.Properties.Color ?? PieceColor.Undefined;
     brand = parameters.Properties.Brand ?? PieceBrand.Undefined;
     shape = parameters.Properties.Shape ?? PieceShape.Undefined;
     size = parameters.Properties.Size ?? PieceSize.Undefined;
     direction = parameters.Direction;
     velocity = parameters.Velocity;
 }
예제 #2
0
        public static bool CanEat(int rule, PieceShape currShape, Piece p1, Piece p2)
        {
            PieceShape shape = Transition(rule, currShape, p2.Shape);

            if (shape == PieceShape.Unknown)
            {
                return(false);
            }
            return(true);
        }
예제 #3
0
        public void SetShape(PieceShape shape)
        {
            switch (shape)
            {
            case PieceShape.Circle:
                meshShape.GetComponent <TextMesh> ().text = "Cir";
                mesh.GetComponent <MeshRenderer>().material.mainTexture = textures[0];
                break;

            case PieceShape.RCircle:
                meshShape.GetComponent <TextMesh> ().text = "Cir_Inv";
                mesh.GetComponent <MeshRenderer>().material.mainTexture = textures[1];
                break;

            case PieceShape.Rect:
                meshShape.GetComponent <TextMesh> ().text = "Rect";
                mesh.GetComponent <MeshRenderer>().material.mainTexture = textures[2];
                break;

            case PieceShape.RRect:
                meshShape.GetComponent <TextMesh> ().text = "Rect_Inv";
                mesh.GetComponent <MeshRenderer>().material.mainTexture = textures[3];
                break;

            case PieceShape.Triangle:
                meshShape.GetComponent <TextMesh> ().text = "Tri";
                mesh.GetComponent <MeshRenderer>().material.mainTexture = textures[4];
                break;

            case PieceShape.RTriangle:
                meshShape.GetComponent <TextMesh> ().text = "Tri_Inv";
                mesh.GetComponent <MeshRenderer>().material.mainTexture = textures[5];
                break;

            case PieceShape.Unknown:
                meshShape.GetComponent <TextMesh> ().text = "No";
                mesh.GetComponent <MeshRenderer>().material.mainTexture = textures[6];
                break;

            default:
                meshShape.GetComponent <TextMesh> ().text = "No";
                mesh.GetComponent <MeshRenderer>().material.mainTexture = textures[6];
                break;
            }
        }
예제 #4
0
파일: PieceSlot.cs 프로젝트: steb-vs/rrr
    // Start is called before the first frame update
    void Start()
    {
        GameHelper.Manager.maxScore++;
        pieceSlot = transform.GetChild(0);
        shapeMesh = GetComponent <MeshFilter>();
        myMat     = GetComponent <Renderer>();

        if (!testing)
        {
            brand = (PieceBrand)Random.Range(1, 4);
            color = (PieceColor)Random.Range(1, 4);
            shape = (PieceShape)Random.Range(1, 4);
            size  = (PieceSize)Random.Range(1, 4);
        }

        //Change color randomly
        switch (color)
        {
        case PieceColor.Red:
            myLight.color = Color.red;
            myMat.material.SetColor("_EmissionColor", Color.red);
            break;

        case PieceColor.Green:
            myLight.color = Color.green;
            myMat.material.SetColor("_EmissionColor", Color.green);
            break;

        case PieceColor.Blue:
            myLight.color = Color.blue;
            myMat.material.SetColor("_EmissionColor", Color.blue);
            break;

        default:
            myLight.color = Color.black;
            myMat.material.SetColor("_EmissionColor", Color.black);
            break;
        }

        switch (shape)
        {
        case PieceShape.Cube:
            shapeMesh.mesh = meshes[0];
            break;

        case PieceShape.Sphere:
            shapeMesh.mesh = meshes[1];
            break;

        case PieceShape.Cylinder:
            shapeMesh.mesh = meshes[2];
            break;

        default:
            shapeMesh.mesh = meshes[0];
            break;
        }
        switch (brand)
        {
        case PieceBrand.Durex:
            myMat.material.SetTexture("_MainTex", textures[0]);
            break;

        case PieceBrand.Lays:
            myMat.material.SetTexture("_MainTex", textures[1]);
            break;

        case PieceBrand.Ikea:
            myMat.material.SetTexture("_MainTex", textures[2]);
            break;

        default:
            myMat.material.SetTexture("_MainTex", textures[0]);
            break;
        }
        switch (size)
        {
        case PieceSize.Small:
            transform.localScale = new Vector3(0.2f, 0.2f, 0.2f);
            break;

        case PieceSize.Medium:
            transform.localScale = new Vector3(0.42f, 0.42f, 0.42f);
            break;

        case PieceSize.Large:
            transform.localScale = new Vector3(0.65f, 0.65f, 0.65f);
            break;

        default:
            transform.localScale = new Vector3(1f, 1f, 1f);
            break;
        }
    }
예제 #5
0
        public static PieceShape Transition(int rule, PieceShape s1, PieceShape s2)
        {
            if (s1 == PieceShape.Rect)
            {
                switch (s2)
                {
                case PieceShape.Rect:
                    return(PieceShape.RRect);

                case PieceShape.Circle:
                    return(PieceShape.Rect);

                default:
                    return(PieceShape.Unknown);
                }
            }

            if (s1 == PieceShape.Circle)
            {
                switch (s2)
                {
                case PieceShape.Triangle:
                    return(PieceShape.Circle);

                case PieceShape.Circle:
                    return(PieceShape.RCircle);

                default:
                    return(PieceShape.Unknown);
                }
            }

            if (s1 == PieceShape.Triangle)
            {
                switch (s2)
                {
                case PieceShape.Triangle:
                    return(PieceShape.RTriangle);

                case PieceShape.Rect:
                    return(PieceShape.Triangle);

                default:
                    return(PieceShape.Unknown);
                }
            }

            if (s1 == PieceShape.RRect)
            {
                switch (s2)
                {
                case PieceShape.Rect:
                    return(PieceShape.Rect);

                case PieceShape.Triangle:
                    return(PieceShape.RRect);

                default:
                    return(PieceShape.Unknown);
                }
            }

            if (s1 == PieceShape.RCircle)
            {
                switch (s2)
                {
                case PieceShape.Rect:
                    return(PieceShape.RCircle);

                case PieceShape.Circle:
                    return(PieceShape.Circle);

                default:
                    return(PieceShape.Unknown);
                }
            }

            if (s1 == PieceShape.RTriangle)
            {
                switch (s2)
                {
                case PieceShape.Circle:
                    return(PieceShape.RTriangle);

                case PieceShape.Triangle:
                    return(PieceShape.Triangle);

                default:
                    return(PieceShape.Unknown);
                }
            }

            return(PieceShape.Unknown);
        }
예제 #6
0
        public static void CheckPath(int rule, Board board, List <Vector2> path, out PieceShape shape, out List <Vector2> finalpath, out List <Vector2> finalneighbors)
        {
            Nullable <Vector2> prev      = null;
            PieceShape         prevShape = PieceShape.Unknown;
            Vector2            curr;
            List <Vector2>     neighbors = new List <Vector2>();
            List <Vector2>     newpath   = new List <Vector2> ();

            foreach (Vector2 pos in path)
            {
                if (isValidPos(board.Size, pos) == false)
                {
                    break;
                }

                if (prev.HasValue)
                {
                    curr = pos;

                    Piece prevPiece = board.GetPiece(prev.Value);
                    Piece currPiece = board.GetPiece(curr);

                    if (CanEat(rule, prevShape, prevPiece, currPiece))
                    {
                        var currShape = Transition(rule, prevShape, currPiece.Shape);
                        if (currShape != PieceShape.Unknown)
                        {
                            prevShape = currShape;
                            newpath.Add(curr);
                        }
                        else
                        {
                            break;
                        }
                    }
                    else
                    {
                        break;
                    }
                    prev = curr;
                }
                else
                {
                    Piece prevPiece = board.GetPiece(pos);
                    prevShape = prevPiece.Shape;
                    prev      = pos;
                    newpath.Add(pos);
                }
            }

            if (prev.HasValue)
            {
                neighbors.Clear();
                var prevPiece = board.GetPiece(prev.Value);
                foreach (var ns in PosNeighbors(board.Size, prev.Value))
                {
                    var nextPiece = board.GetPiece(ns);
                    if (CanEat(rule, prevShape, prevPiece, nextPiece))
                    {
                        neighbors.Add(ns);
                    }
                }
                neighbors = neighbors.Where((pos) => {
                    return(!newpath.Exists((pos2) => {
                        return pos.x == pos2.x && pos.y == pos2.y;
                    }));
                }).ToList();
            }

            shape          = prevShape;
            finalpath      = newpath;
            finalneighbors = neighbors;
        }
예제 #7
0
파일: Piece.cs 프로젝트: VicYu1983/spaceWar
 public Piece(PieceShape shape)
 {
     this.shape = shape;
 }
예제 #8
0
파일: PieceComp.cs 프로젝트: steb-vs/rrr
    public void SetParameters(PieceParameters parameters)
    {
        color = parameters.Properties.Color ?? PieceColor.Undefined;
        brand = parameters.Properties.Brand ?? PieceBrand.Undefined;
        shape = parameters.Properties.Shape ?? PieceShape.Undefined;
        size  = parameters.Properties.Size ?? PieceSize.Undefined;

        //Change color randomly
        switch (color)
        {
        case PieceColor.Red:
            myLight.color = Color.red;
            break;

        case PieceColor.Green:
            myLight.color = Color.green;
            break;

        case PieceColor.Blue:
            myLight.color = Color.blue;
            break;

        default:
            myLight.color = Color.black;
            break;
        }

        shapeMesh = GetComponent <MeshFilter>();
        switch (shape)
        {
        case PieceShape.Cube:
            shapeMesh.mesh = meshes[0];
            break;

        case PieceShape.Sphere:
            shapeMesh.mesh = meshes[1];
            break;

        case PieceShape.Cylinder:
            shapeMesh.mesh = meshes[2];
            break;

        default:
            shapeMesh.mesh = meshes[0];
            break;
        }
        myMat = GetComponent <Renderer>();
        switch (brand)
        {
        case PieceBrand.Durex:
            myMat.material.SetTexture("_MainTex", textures[0]);
            break;

        case PieceBrand.Lays:
            myMat.material.SetTexture("_MainTex", textures[1]);
            break;

        case PieceBrand.Ikea:
            myMat.material.SetTexture("_MainTex", textures[2]);
            break;

        default:
            myMat.material.SetTexture("_MainTex", textures[0]);
            break;
        }
        switch (size)
        {
        case PieceSize.Small:
            transform.localScale = new Vector3(0.2f, 0.2f, 0.2f);
            break;

        case PieceSize.Medium:
            transform.localScale = new Vector3(0.42f, 0.42f, 0.42f);
            break;

        case PieceSize.Large:
            transform.localScale = new Vector3(0.65f, 0.65f, 0.65f);
            break;

        default:
            transform.localScale = new Vector3(1f, 1f, 1f);
            break;
        }
    }
예제 #9
0
        public GamePiece(PieceShape shape, BlockColors color, Vector2 position, int blockSize, Texture2D squares)
        {
            Position        = position;
            Shape           = shape;
            rotationCounter = 0;
            squaresTexture  = squares;

            PieceBlocks = new Block[ARRAY_SIZE, ARRAY_SIZE];

            for (int a = 0; a < ARRAY_SIZE; a++)
            {
                for (int b = 0; b < ARRAY_SIZE; b++)
                {
                    PieceBlocks[a, b]           = new Block();
                    PieceBlocks[a, b].Type      = BlockTypes.Empty;
                    PieceBlocks[a, b].Width     = blockSize;
                    PieceBlocks[a, b].Height    = blockSize;
                    PieceBlocks[a, b].Position  = new Vector2(a * blockSize + position.X, b * blockSize + Position.Y);
                    PieceBlocks[a, b].Rectangle = new Rectangle((int)(a * blockSize + Position.X),
                                                                (int)(b * blockSize + Position.Y), blockSize, blockSize);
                    PieceBlocks[a, b].SquareTextures = squares;
                    PieceBlocks[a, b].BlockColor     = color;
                }
            }

            switch (shape)
            {
            case PieceShape.I:
            {
                PieceBlocks[2, 1].Type       = BlockTypes.Moving;
                PieceBlocks[2, 1].BlockColor = color;
                PieceBlocks[2, 2].Type       = BlockTypes.Moving;
                PieceBlocks[2, 2].BlockColor = color;
                PieceBlocks[2, 3].Type       = BlockTypes.Moving;
                PieceBlocks[2, 3].BlockColor = color;
                PieceBlocks[2, 4].Type       = BlockTypes.Moving;
                PieceBlocks[2, 4].BlockColor = color;
                break;
            }

            case PieceShape.J:
            {
                PieceBlocks[2, 1].Type       = BlockTypes.Moving;
                PieceBlocks[2, 1].BlockColor = color;
                PieceBlocks[2, 2].Type       = BlockTypes.Moving;
                PieceBlocks[2, 2].BlockColor = color;
                PieceBlocks[2, 3].Type       = BlockTypes.Moving;
                PieceBlocks[2, 3].BlockColor = color;
                PieceBlocks[1, 3].Type       = BlockTypes.Moving;
                PieceBlocks[1, 3].BlockColor = color;
                break;
            }

            case PieceShape.L:
            {
                PieceBlocks[2, 1].Type       = BlockTypes.Moving;
                PieceBlocks[2, 1].BlockColor = color;
                PieceBlocks[2, 2].Type       = BlockTypes.Moving;
                PieceBlocks[2, 2].BlockColor = color;
                PieceBlocks[2, 3].Type       = BlockTypes.Moving;
                PieceBlocks[2, 3].BlockColor = color;
                PieceBlocks[3, 3].Type       = BlockTypes.Moving;
                PieceBlocks[3, 3].BlockColor = color;
                break;
            }

            case PieceShape.S:
            {
                PieceBlocks[1, 3].Type       = BlockTypes.Moving;
                PieceBlocks[1, 3].BlockColor = color;
                PieceBlocks[2, 2].Type       = BlockTypes.Moving;
                PieceBlocks[2, 2].BlockColor = color;
                PieceBlocks[2, 3].Type       = BlockTypes.Moving;
                PieceBlocks[2, 3].BlockColor = color;
                PieceBlocks[3, 2].Type       = BlockTypes.Moving;
                PieceBlocks[3, 2].BlockColor = color;
                break;
            }

            case PieceShape.Z:
            {
                PieceBlocks[1, 2].Type       = BlockTypes.Moving;
                PieceBlocks[1, 2].BlockColor = color;
                PieceBlocks[2, 2].Type       = BlockTypes.Moving;
                PieceBlocks[2, 2].BlockColor = color;
                PieceBlocks[2, 3].Type       = BlockTypes.Moving;
                PieceBlocks[2, 3].BlockColor = color;
                PieceBlocks[3, 3].Type       = BlockTypes.Moving;
                PieceBlocks[3, 3].BlockColor = color;
                break;
            }

            case PieceShape.Square:
            {
                PieceBlocks[1, 1].Type       = BlockTypes.Moving;
                PieceBlocks[1, 1].BlockColor = color;
                PieceBlocks[1, 2].Type       = BlockTypes.Moving;
                PieceBlocks[1, 2].BlockColor = color;
                PieceBlocks[2, 2].Type       = BlockTypes.Moving;
                PieceBlocks[2, 2].BlockColor = color;
                PieceBlocks[2, 1].Type       = BlockTypes.Moving;
                PieceBlocks[2, 1].BlockColor = color;
                break;
            }

            case PieceShape.T:
            {
                PieceBlocks[1, 2].Type       = BlockTypes.Moving;
                PieceBlocks[1, 2].BlockColor = color;
                PieceBlocks[2, 2].Type       = BlockTypes.Moving;
                PieceBlocks[2, 2].BlockColor = color;
                PieceBlocks[2, 3].Type       = BlockTypes.Moving;
                PieceBlocks[2, 3].BlockColor = color;
                PieceBlocks[3, 2].Type       = BlockTypes.Moving;
                PieceBlocks[3, 2].BlockColor = color;
                break;
            }
            }
        }