コード例 #1
0
ファイル: Brick.cs プロジェクト: local-minimum/YeastBatch
 private void OnDestroy()
 {
     Match.OnPlayerTurn -= HandlePlayerTurn;
     if (LeftSelectBrick == this)
     {
         LeftSelectBrick = null;
     }
     if (RightSelectBrick == this)
     {
         RightSelectBrick = null;
     }
     if (HoverBrick == this)
     {
         HoverBrick = null;
     }
     UITileStatus.Clear(tile);
 }
コード例 #2
0
ファイル: Brick.cs プロジェクト: local-minimum/YeastBatch
    private void Update()
    {
        if (UIPopAction.Showing || UIWinner.hasWinner)
        {
            return;
        }

        if (HoverBrick == this)
        {
            bool hasPop = tile.HasPopulation(Match.ActivePlayer);

            if (Input.GetMouseButtonDown(0))
            {
                if (hasPop)
                {
                    LeftSelectBrick = this;
                    buttonDownTime  = Time.timeSinceLevelLoad;
                }
                else
                {
                    LeftSelectBrick = null;
                }
            }

            if (LeftSelectBrick)
            {
                if (Input.GetMouseButtonUp(0))
                {
                    if (HoverBrick == LeftSelectBrick)
                    {
                        UIPopAction.ShowFor(tile);
                    }
                    else
                    {
                        LeftSelectBrick.IllustrateSelection(this, true);
                        LeftSelectBrick.SetTileAction(this);
                    }
                    LeftSelectBrick = null;
                }
                else if (Input.GetMouseButton(0))
                {
                    LeftSelectBrick.IllustrateSelection(this, false);
                }
            }

            if (Input.GetMouseButtonDown(1))
            {
                RightSelectBrick = this;
                Debug.Log("Right Select " + RightSelectBrick);
            }
            else if (RightSelectBrick)
            {
                if (Input.GetMouseButtonUp(1))
                {
                    Debug.Log("Right Select Complete " + RightSelectBrick);
                    if (RightSelectBrick == this)
                    {
                        Debug.Log("Clear");
                        tile.ClearPlan();
                        ClearPlanIllustration();
                    }
                    RightSelectBrick = null;
                }
            }
        }

        if (clearBrickWithDelay)
        {
            if (HoverBrick == null)
            {
                if (Time.timeSinceLevelLoad > clearTime)
                {
                    UITileStatus.Clear(tile);
                    clearBrickWithDelay = false;
                }
            }
            else
            {
                clearBrickWithDelay = false;
            }
        }
    }