示例#1
0
    protected void onDiskDown(IntVector2 pos)
    {
        int id = RackUtil.checkWin();

        if (id > 0)
        {
            playerWon(id);
        }
        else
        {
            if (pos == GameUtil.currentSpecial)
            {
                //activateDelete();
                if (GameUtil.onTurn)
                {
                    GameUtil.special1 = Random.Range(1, 4);
                }
                else
                {
                    GameUtil.special2 = Random.Range(1, 4);
                }
                GameUtil.playOneShot("SpecialPickUp");
                rack.createSpecial(newSpecialLocation());
            }
            GameUtil.onTurn = !GameUtil.onTurn;
            rack.showDiskSelector();
        }
    }
示例#2
0
    protected void onDiskDown(IntVector2 pos)
    {
        int id = RackUtil.checkWin();

        if (id > 0)
        {
            playerWon(id);
        }
        else
        {
            if (pos == GameUtil.currentSpecial)
            {
                //activateDelete();
                if (GameUtil.onTurn)
                {
                    GameUtil.special1 = UnityEngine.Random.Range(1, 4);
                }
                else
                {
                    GameUtil.special2 = UnityEngine.Random.Range(1, 4);
                }
                GameUtil.playOneShot("SpecialPickUp");
                IntVector2 v = newSpecialLocation();
                NetworkManager.postNewSpecial(v.x, v.y);
                rack.createSpecial(v);
            }
        }
    }
示例#3
0
    IEnumerator RotateRack(Vector3 angle, float inTime)
    {
        var fromAngle = container.transform.rotation;
        var toAngle   = Quaternion.Euler(angle);

        RackUtil.shiftRackToLeft();

        for (var t = 0f; t < 1; t += Time.deltaTime / inTime)
        {
            container.transform.rotation = Quaternion.Lerp(fromAngle, toAngle, t);
            for (int i = 0; i < RackUtil.SIZE; i++)
            {
                for (int j = 0; j < RackUtil.SIZE; j++)
                {
                    if (RackUtil.myRack [i] [j].id != 0)
                    {
                        updateRackItemBy(i, j, t);
                    }
                }
            }
            yield return(null);
        }
        container.transform.rotation = Quaternion.Euler(angle);

        //Rotates the array 90 degrees
        RackUtil.transposeRack();
        RackUtil.flipRackColumns();

        normalizePositionsAfterRotation();
        GameUtil.isAnimating = false;
        RackRotatedCallback();
    }
示例#4
0
    //Called after rack's animation finishes
    protected void rackRotated()
    {
        rack.createSpecial(newSpecialLocation());
        int id = RackUtil.checkWin();

        if (id > 0)
        {
            playerWon(id);
        }
    }
示例#5
0
 public void opponentDropDisk(int column)
 {
     if (!RackUtil.isColumnFull(column))
     {
         rack.hideSelector();
         GameUtil.onTurn = false;
         var pos = rack.dropDisk(column);
         onDiskDown(pos);
     }
 }
示例#6
0
    protected void dropDisk()
    {
        var column = (GameUtil.mousePosition().x + 30) / 10;

        if (!RackUtil.isColumnFull(column))
        {
            rack.hideSelector();
            var pos = rack.dropDisk(column);
            onDiskDown(pos);
        }
    }
示例#7
0
 public void deleteAllDisks()
 {
     for (int i = 0; i < RackUtil.SIZE; i++)
     {
         for (int j = 0; j < RackUtil.SIZE; j++)
         {
             var disk = RackUtil.myRack [i] [j].disk;
             RackUtil.deleteDisk(i, j);
             Destroy(disk);
         }
     }
 }
示例#8
0
 public void deleteColumn(int column)
 {
     GameUtil.isAnimating = true;
     for (int i = 0; i < RackUtil.SIZE; i++)
     {
         var disk = RackUtil.myRack [i] [column].disk;
         RackUtil.deleteDisk(i, column);
         Destroy(disk);
     }
     StartCoroutine(ColumnDeleteTask());
     GameUtil.playOneShot("Special activate");
 }
示例#9
0
    protected void dropDisk()
    {
        var column = (GameUtil.mousePosition().x + 30) / 10;

        if (!RackUtil.isColumnFull(column))
        {
            rack.hideSelector();
            var pos = rack.dropDisk(column);
            onDiskDown(pos);
            GameUtil.onTurn = false;
            NetworkManager.postDropDisk(column, true);
        }
    }
示例#10
0
    //Called after rack's animation finishes
    protected void rackRotated()
    {
        IntVector2 v = newSpecialLocation();

        NetworkManager.postNewSpecial(v.x, v.y);
        rack.createSpecial(v);
        int id = RackUtil.checkWin();

        if (id > 0)
        {
            playerWon(id);
        }
    }
示例#11
0
 public void deleteRow(int row)
 {
     for (int i = 0; i < RackUtil.SIZE; i++)
     {
         var disk = RackUtil.myRack [row] [i].disk;
         RackUtil.deleteDisk(row, i);
         Destroy(disk);
     }
     GameUtil.isAnimating = true;
     StartCoroutine(RowDeleteTask(row, 0.5f));
     GameUtil.playOneShot("InGameSound");
     GameUtil.playOneShot("Special activate");
 }
示例#12
0
    public IntVector2 dropDisk(int column)
    {
        var clone = GameObject.Instantiate(prefab);

        clone.transform.SetParent(container.transform);
        clone.transform.localPosition = new Vector2(column * 10 - 30, 41);
        clone.GetComponent <SpriteRenderer> ().color = GameUtil.onTurn?Color.red:Color.yellow;
        var id          = GameUtil.onTurn ? 1 : 2;
        var coordinates = RackUtil.registerDisk(column, id, clone);

        GameUtil.isAnimating = true;
        StartCoroutine(updateRackItem(coordinates.x, coordinates.y));
        GameUtil.playOneShot("InGameSound");
        return(coordinates);
    }
示例#13
0
    // Use this for initialization
    void Start()
    {
        RackUtil.initRacks();
        rack = MyRack.getInstance();
        GameUtil.specialButton = GameObject.Find("SpecialButton");
        GameUtil.resetButton   = GameObject.Find("ResetButton");

        //Handling delegates
        rack.DiskDroppedCallback   += diskDropped;
        rack.RackRotatedCallback   += rackRotated;
        rack.ColumnDeletedCallback += columnDeleted;
        rack.RowDeletedCallback    += rowDeleted;
        GameUtil.setResetHandler(resetPressed);
        GameUtil.setSpecialHandler(specialPressed);
        setupGame();
    }
示例#14
0
    IEnumerator RowDeleteTask(int row, float inTime)
    {
        RackUtil.shiftRackDown();

        for (var t = 0f; t < 1; t += Time.deltaTime / inTime)
        {
            for (int i = 0; i < RackUtil.SIZE; i++)
            {
                for (int j = 0; j < RackUtil.SIZE; j++)
                {
                    if (RackUtil.myRack [i] [j].id != 0)
                    {
                        updateRackItemBy(i, j, t);
                    }
                }
            }
            yield return(null);
        }
        RowDeletedCallback(row);
    }