Ejemplo n.º 1
0
    //Attempts to add a given square to a column in the build zone, returns true if the square was properly added, false if there is no space in the column
    public bool AddSquare(int col, SquareController square, int player)
    {
        int count = buildGrid[col].Count;

        //Check if a half Gold block pairs with a priorly dropped half gold block in the same col
        if (count > 0 && GoldMatch(square, buildGrid[col][count - 1]))
        {
            int gHeight = count - 1;
            while (gHeight > 0 && GoldMatch(square, buildGrid[col][gHeight - 1]))
            {
                gHeight--;
            }
            //Link both halves to each other for scoring and falling purposes
            buildGrid[col][gHeight].pair = square;
            square.pair = buildGrid[col][gHeight];
            square.transform.position = GridLocation[0][col, height];
            square.SetZone(true, "Build", GridLocation[0][col, gHeight], col, gHeight);

            if (Manager.NumPlayers == 2)
            {
                square.mirror = PlayZoneController.instance.GetMirror(square);
                square.mirror.transform.position = GridLocation[1][col, height];
                square.mirror.SetZone(true, "Build", GridLocation[1][col, gHeight], col, gHeight);
            }
            AnalyticsManager.instance.FillEventLog("Block Dropped In Drop Zone", player, square);
            return(true);
        }
        //Checks to see if the column is filled
        if (count < height)
        {
            //Tells the square it is now in the "Build" zone and which column and row it will end up in
            square.transform.position = GridLocation[0][col, height];
            square.SetZone(true, "Build", GridLocation[0][col, count], col, count);
            buildGrid[col].Add(square);

            if (Manager.NumPlayers == 2)
            {
                square.mirror = PlayZoneController.instance.GetMirror(square);
                square.mirror.transform.position = GridLocation[1][col, height];
                square.mirror.SetZone(true, "Build", GridLocation[1][col, count], col, count);
            }
            AnalyticsManager.instance.FillEventLog("Block Dropped In Drop Zone", player, square);
            return(true);
        }
        //If it reaches this point without returning, the column is full, it can't fit any more blocks
        return(false);
    }
Ejemplo n.º 2
0
    public void DropBlock(SquareController block, int col)
    {
        fallingBlocks.Add(block);
        block.transform.position = dropLocs[col];
        block.SetZone(true, "Play", endLocs[col], col);
        spawningPool.Remove(block);

        //Tell the sound script to play the corresponding sound
        //at the blockDropSounds AudioSource. -Nathan
        //REMOVED, TRENT SAYS TOO MUCH STIMULI
        //SoundManager.instance.soundPlay(0, col + 2);
    }
Ejemplo n.º 3
0
    public void SetGrabbedObject(GameObject obj)
    {
        grabbedObject = obj;
        SquareController grabbedSquare = grabbedObject.GetComponent <SquareController>();

        grabDistance = Vector3.Distance(hand.transform.position, hit.point);
        if (grabbedSquare.zone == "Play")
        {
            grabbedSquare.SetZone(false, "Interact", grabbedSquare.transform.position);
        }
        if (Manager.NumPlayers == 1 || grabbedSquare.type != 2)
        {
            grabbedObject.layer = 2;
        }
        grabbedSquare.playerHolds[player] = true;
    }
Ejemplo n.º 4
0
    public void RecycleBlock(SquareController block)
    {
        fallingBlocks.Remove(block);
        if (block.isMirror)
        {
            mirrorPool[block.type].Add(block);
        }
        else
        {
            switch (block.type)
            {
            case 2:
                if (block.zone == "Build" && Manager.NumPlayers == 2)
                {
                    goldMergePool.Add(block);
                }
                else
                {
                    spawningPool.Add(block);
                }
                break;

            case 3:
                goldLeftPool.Add(block);
                break;

            case 4:
                goldRightPool.Add(block);
                break;

            default:
                spawningPool.Add(block);
                break;
            }
        }

        block.playerHolds[0]     = false;
        block.playerHolds[1]     = false;
        block.gameObject.layer   = 1;
        block.transform.position = new Vector3(1000, 0, 0);
        block.SetZone(false, "Pool", new Vector3(1000, 0, 0));
        block.dirty = false;
    }
Ejemplo n.º 5
0
    /// <summary>
    /// Pre logic used to determine who the object was grabbed by and where it was interacted with.
    /// </summary>
    /// <param name="obj"> Object in question. </param>
    public void SetGrabbedObject(GameObject obj)
    {
        grabbedObject = obj;
        Debug.Log("grabbed object: " + obj.name);
        SquareController grabbedSquare = grabbedObject.GetComponent <SquareController>();

        AnalyticsManager.instance.FillEventLog("Grabbed Block", handNum, grabbedSquare);
        grabbedSquare.grabbed = true;
        grabDistance          = Vector3.Distance(MyHand.transform.position, hit.point);
        if (grabbedSquare.zone == "Play" || grabbedSquare.zone == "Pool")
        {
            grabbedSquare.SetZone(false, "Interact", grabbedSquare.transform.position);
        }
        if ((Manager.NumPlayers == 1 || grabbedSquare.type != 2) && grabbedSquare.zone != "Build")
        {
            grabbedObject.layer = 2;
        }
        grabbedSquare.playerHolds[transform.tag.Contains("Self")?0:1] = true;
        goldHoldTimer = 0.0f;
    }