Пример #1
0
 public static R Else <T, U, R>(this MatchValue <T, U, R> @this, Func <T, R> elseResult)
 {
     if (@this.HasResult)
     {
         return(@this.Result);
     }
     return(elseResult(@this.Value));
 }
Пример #2
0
    // drops a Bomb at a position (x,y) in the Board, given a list of matching GamePieces
    public GameObject DropBomb(int x, int y, Vector2 swapDirection, List <GamePiece> gamePieces)
    {
        GameObject bomb       = null;
        MatchValue matchValue = MatchValue.None;

        if (gamePieces != null)
        {
            matchValue = board.boardQuery.FindMatchValue(gamePieces);
        }

        // check if the GamePieces are four or more in a row
        if (gamePieces.Count >= 5 && matchValue != MatchValue.None)
        {
            // check if we form a corner match and create an adjacent bomb
            if (board.boardQuery.IsCornerMatch(gamePieces))
            {
                GameObject adjacentBomb = board.boardQuery.FindGamePieceByMatchValue(board.adjacentBombPrefabs, matchValue);

                if (adjacentBomb != null)
                {
                    bomb = board.boardFiller.MakeBomb(adjacentBomb, x, y);
                }
            }
            else
            {
                // if have five or more in a row, form a color bomb - note we probably should swap this upward to
                // give it priority over an adjacent bomb

                if (board.colorBombPrefab != null)
                {
                    bomb = board.boardFiller.MakeBomb(board.colorBombPrefab, x, y);
                }
            }
        }
        else if (gamePieces.Count == 4 && matchValue != MatchValue.None)
        {
            // otherwise, drop a row bomb if we are swiping sideways
            if (Mathf.Abs(swapDirection.x) > 0.01f)
            {
                GameObject rowBomb = board.boardQuery.FindGamePieceByMatchValue(board.rowBombPrefabs, matchValue);
                if (rowBomb != null)
                {
                    bomb = board.boardFiller.MakeBomb(rowBomb, x, y);
                }
            }
            else
            {
                GameObject columnBomb = board.boardQuery.FindGamePieceByMatchValue(board.columnBombPrefabs, matchValue);
                // or drop a vertical bomb if we are swiping upwards
                if (columnBomb != null)
                {
                    bomb = board.boardFiller.MakeBomb(columnBomb, x, y);
                }
            }
        }
        // return the Bomb object
        return(bomb);
    }
Пример #3
0
 /// <summary>
 ///     获取MatchItem
 /// </summary>
 /// <returns></returns>
 public BsonDocument GetMatchItem()
 {
     if (!string.IsNullOrEmpty(cmbField.Text))
     {
         return(new BsonDocument(cmbField.Text,
                                 new BsonDocument(cmbComparisonfunction.Text, MatchValue.GetValue())));
     }
     return(null);
 }
Пример #4
0
    GameObject DropBomb(int x, int y, Vector2 swapDirection, List <GamePiece> gamePieces)
    {
        GameObject bomb       = null;
        MatchValue matchValue = MatchValue.none;

        if (gamePieces != null)
        {
            matchValue = FindMatchValue(gamePieces);
        }

        if (gamePieces.Count >= 5 && matchValue != MatchValue.none)
        {
            if (IsCornerMatch(gamePieces))
            {
                GameObject adjacentBomb = FindGamePieceByMatchValue(adjacentBombPrefabs, matchValue);

                if (adjacentBomb != null)
                {
                    bomb = MakeBomb(adjacentBomb, x, y, true);
                }
            }
            else
            {
                if (ColorBombPrefab != null)
                {
                    bomb = MakeBomb(ColorBombPrefab, x, y, false);
                }
            }
        }
        else if (gamePieces.Count == 4 && matchValue != MatchValue.none)
        {
            if (swapDirection.x != 0)
            {
                GameObject rowBomb = FindGamePieceByMatchValue(rowBombPrefabs, matchValue);

                if (rowBomb != null)
                {
                    bomb = MakeBomb(rowBomb, x, y, true);
                }
            }
            else
            {
                GameObject columnBomb = FindGamePieceByMatchValue(columnBombPrefabs, matchValue);

                if (columnBomb != null)
                {
                    bomb = MakeBomb(columnBomb, x, y, true);
                }
            }
        }
        if (bomb)
        {
            spawnedPieces.Add(bomb);
        }
        return(bomb);
    }
Пример #5
0
        public void T()
        {
            #region 市政取芯数据录入求值
            sql = $"select m.*,s.jcxm,s.BZMD_S1 from {ysjbmc} m inner join {sjbmc} e on e.recid = m.sysjbrecid inner join s_lqx s on s.recid = e.sysjbrecid  where m.sysjbrecid = '{recid}' ";
            dt  = CommonDao.GetDataTableTran(sql);
            if (dt.Count > 0)
            {
                var    dic  = dt[0];
                string jcxm = "、" + dic["jcxm"].Replace(',', '、') + "、";
                if (jcxm.Contains("、厚度、"))
                {
                    dic["hd"] = Math.Round((dic["schd1"].GetSafeDouble() + dic["schd2"].GetSafeDouble() + dic["schd3"].GetSafeDouble() + dic["schd4"].GetSafeDouble()) / 4, 2).ToString("0.00");
                }
                else
                {
                    dic["hd"] = "----";
                }

                if (jcxm.Contains("、密度(表干法、水中法、蜡封法)、"))
                {
                    if (dic["syff"] == "表干法" || dic["syff"] == "水中重法")
                    {
                        dic["md"] = Math.Round(dic["kqzzl"].GetSafeDouble() / (dic["bgzl"].GetSafeDouble() - dic["szzl"].GetSafeDouble()) * 0.9771, 3).ToString("F3");
                    }
                    else if (dic["syff"] == "蜡封法")
                    {
                        if (dic["sfhs"] == "是")   //用滑石粉
                        {
                            dic["md"] = Math.Round(dic["sjkz"].GetSafeDouble() / ((dic["lkzl"].GetSafeDouble() - dic["lszl"].GetSafeDouble()) - ((dic["lkzl"].GetSafeDouble() - dic["thkz"].GetSafeDouble()) / dic["slmd"].GetSafeDouble() + (dic["thkz"].GetSafeDouble() - dic["sjkz"].GetSafeDouble()) / dic["hsmd"].GetSafeDouble())) * 0.9771, 3).ToString("F3");
                        }
                        else
                        {
                            dic["md"] = Math.Round(dic["sjkz"].GetSafeDouble() / ((dic["lkzl"].GetSafeDouble() - dic["lszl"].GetSafeDouble()) - (dic["lkzl"].GetSafeDouble() - dic["sjkz"].GetSafeDouble()) / dic["slmd"].GetSafeDouble()) * 0.9771, 3).ToString("F3");
                        }
                    }
                    else
                    {
                        dic["syff"] = "----";
                    }

                    if (MatchValue.IsNumeric(dic["md"]) && MatchValue.IsNumeric(dic["BZMD_S1"]))
                    {
                        dic["YSD"] = Math.Round(dic["md"].GetSafeDouble() / dic["BZMD_S1"].GetSafeDouble() * 100, 2).GetSafeString();
                    }
                }
                else
                {
                    dic["syff"] = "----";
                }
                upsqls.Add($"update {ysjbmc} set hd = '{dic["hd"]}',ysd = '{dic["ysd"]}' where sysjbrecid = '{recid}'");
                upsqls.Add($"update {sjbmc} set SCHD = '{dic["hd"]}',SCYSD = '{dic["ysd"]}',MD = '{dic["md"]}' where recid = '{recid}'");
            }
            #endregion
        }
Пример #6
0
 public static MatchValue <T, U, R> Case <T, U, R>(this MatchValue <T, U, R> @this, U @that, Func <T, R> action)
 {
     if (@this.HasResult)
     {
         return(@this);
     }
     if (@this.Predicate(@this.Value).Equals(@that))
     {
         return(MatchValue <T, U, R> .Of(@this.Value, @this.Predicate, action(@this.Value)));
     }
     return(@this);
 }
Пример #7
0
    // Generate bomb objects for game board
    public GameObject InitializeBomb(int x, int y, Vector2 swapDirection, List <GamePiece> gamePieces)
    {
        GameObject bomb       = null;
        MatchValue matchValue = MatchValue.None;

        if (gamePieces != null)
        {
            matchValue = FindMatchValue(gamePieces);
        }

        if (gamePieces.Count >= 5 && matchValue != MatchValue.None)
        {
            if (IsCornerMatch(gamePieces))
            {
                GameObject adjacentBomb = FindGamePieceByMatchValue(adjacentBombPrefabs, matchValue);

                if (adjacentBomb != null)
                {
                    bomb = CreateBomb(adjacentBomb, x, y);
                }
            }
            else
            {
                if (colorBombPrefab != null)
                {
                    bomb = CreateBomb(colorBombPrefab, x, y);
                }
            }
        }
        else if (gamePieces.Count == 4 && matchValue != MatchValue.None)
        {
            if (swapDirection.x != 0)
            {
                GameObject rowBomb = FindGamePieceByMatchValue(rowBombPrefabs, matchValue);

                if (rowBomb != null)
                {
                    bomb = CreateBomb(rowBomb, x, y);
                }
            }
            else
            {
                GameObject columnBomb = FindGamePieceByMatchValue(columnBombPrefabs, matchValue);

                if (columnBomb != null)
                {
                    bomb = CreateBomb(columnBomb, x, y);
                }
            }
        }

        return(bomb);
    }
Пример #8
0
 public static MatchValue <T, U, R> Case <T, U, R>(this MatchValue <T, U, R> @this, Predicate <T> condition, Func <T, R> action)
 {
     if (@this.HasResult)
     {
         return(@this);
     }
     if (condition(@this.Value))
     {
         return(MatchValue <T, U, R> .Of(@this.Value, @this.Predicate, action(@this.Value)));
     }
     return(@this);
 }
Пример #9
0
    public GameObject DropBomb(int x, int y, Vector2 swapDirection, List <Bubble> bubbles)
    {
        GameObject bomb       = null;
        MatchValue matchValue = MatchValue.None;

        if (bubbles != null)
        {
            matchValue = m_board.boardQuery.FindMatchValue(bubbles);
        }

        // Only drop a bomb if player matched 4 or more
        if (bubbles.Count >= 4 && matchValue != MatchValue.None)
        {
            if (m_board.boardQuery.IsCornerMatch(bubbles))
            {
                // Adjacent bomb
                GameObject adjacentBomb = m_board.boardQuery.FindByMatchValue(m_board.adjacentBombPrefabs, matchValue);
                if (adjacentBomb != null)
                {
                    bomb = m_board.boardFiller.MakeBomb(adjacentBomb, x, y);
                }
            }
            else if (bubbles.Count >= 5)
            {
                // Color bomb
                if (m_board.colorBombPrefab != null)
                {
                    bomb = m_board.boardFiller.MakeBomb(m_board.colorBombPrefab, x, y);
                }
            }
            else if (swapDirection.x != 0)
            {
                // Row bomb
                GameObject rowBomb = m_board.boardQuery.FindByMatchValue(m_board.rowBombPrefabs, matchValue);
                if (rowBomb != null)
                {
                    bomb = m_board.boardFiller.MakeBomb(rowBomb, x, y);
                }
            }
            else
            {
                // Column bomb
                GameObject columnBomb = m_board.boardQuery.FindByMatchValue(m_board.columnBombPrefabs, matchValue);
                if (columnBomb != null)
                {
                    bomb = m_board.boardFiller.MakeBomb(columnBomb, x, y);
                }
            }
        }

        return(bomb);
    }
Пример #10
0
    GameObject DropBomb(int x, int y, Vector2 swapDirection, List <GamePiece> gamePieces)
    {
        GameObject bomb       = null;
        MatchValue matchValue = MatchValue.None;

        if (gamePieces != null)
        {
            matchValue = FindMatchValue(gamePieces); //evaluate what type of bomb we droppin.
        }

        if (gamePieces.Count >= 5 && matchValue != MatchValue.None)
        {
            if (IsCornerMatch(gamePieces))
            {
                GameObject adjacentBomb = FindGamePieceByMatchValue(adjacentBombPrefabs, matchValue);

                if (adjacentBomb != null)
                {
                    bomb = MakeBomb(adjacentBomb, x, y);
                }
            }
            else
            {
                //GameObject colorBomb = FindGamePieceByMatchValue(colorBombPrefab, matchValue);
                if (colorBombPrefab != null)
                {
                    bomb = MakeBomb(colorBombPrefab, x, y);
                }
            }
        }
        else if (gamePieces.Count == 4 && matchValue != MatchValue.None)
        {
            if (swapDirection.x != 0)
            {
                GameObject rowBomb = FindGamePieceByMatchValue(rowBombPrefabs, matchValue);

                if (rowBomb != null)
                {
                    bomb = MakeBomb(rowBomb, x, y);
                }
            }
            else
            {
                GameObject columnBomb = FindGamePieceByMatchValue(columnBombPrefabs, matchValue);
                if (columnBomb != null)
                {
                    bomb = MakeBomb(columnBomb, x, y);
                }
            }
        }
        return(bomb);
    }
Пример #11
0
        public override void ExecuteCmdlet()
        {
            var matchCondition = new PSMatchCondition
            {
                MatchVariable    = MatchVariable,
                MatchValue       = MatchValue.ToList(),
                NegateCondition  = !this.IsParameterBound(c => c.NegateCondition)? false : NegateCondition,
                OperatorProperty = OperatorProperty,
                Selector         = Selector
            };

            WriteObject(matchCondition);
        }
Пример #12
0
        public override void ExecuteCmdlet()
        {
            var matchCondition = new PSRulesEngineMatchCondition
            {
                RulesEngineMatchVariable = MatchVariable,
                RulesEngineMatchValue    = MatchValue.ToList(),
                Selector            = this.IsParameterBound(c => c.Selector) ? Selector : null,
                RulesEngineOperator = this.IsParameterBound(c => c.Operator) ? Operator : PSRulesEngineOperator.Any,
                NegateCondition     = this.IsParameterBound(c => c.NegateCondition) ? NegateCondition : false,
                Transforms          = this.IsParameterBound(c => c.Transform) ? Transform.ToList() : new List <PSTransform>()
            };

            WriteObject(matchCondition);
        }
Пример #13
0
    public void ChangeColor(GamePiece pieceToMatch)
    {
        SpriteRenderer rendererToChange = GetComponent <SpriteRenderer>();

        if (pieceToMatch != null)
        {
            SpriteRenderer renderToMatch = pieceToMatch.GetComponent <SpriteRenderer>();
            if (renderToMatch != null && rendererToChange != null)
            {
                rendererToChange.color = renderToMatch.color;
            }
            matchValue = pieceToMatch.matchValue;
        }
    }
Пример #14
0
    public void PlayPoints(MatchValue value)
    {
        foreach (ParticleSystem ps in allParticles)
        {
            ParticleSystem.MainModule ma = ps.main;

            if (value == MatchValue.Green)
            {
                ma.startColor = Color.green;
            }

            else if (value == MatchValue.Blue)
            {
                ma.startColor = Color.blue;
            }
            else if (value == MatchValue.Yellow)
            {
                ma.startColor = Color.yellow;
            }
            else if (value == MatchValue.Red)
            {
                ma.startColor = Color.red;
            }
            else if (value == MatchValue.Purple)
            {
                ma.startColor = Color.magenta;
            }
            else if (value == MatchValue.White)
            {
                ma.startColor = Color.white;
            }
            else if (value == MatchValue.Barrel || value == MatchValue.BrokenBarrel || value == MatchValue.Litter)
            {
                ma.startColor = Color.grey;
            }

            else
            {
                ma.startColor = Color.cyan;
            }


            ps.Stop();

            ps.Play();
        }

        Destroy(gameObject, lifetime);
    }
Пример #15
0
        public override string ToQueryStringParameter()
        {
            string encoded;

            if (IsUnary)
            {
                encoded = Operator.Token + AttributeName;
            }
            else
            {
                encoded = $"{AttributeName}{Operator.Token}\'{Uri.EscapeDataString(MatchValue.ToString())}\'";
            }

            return(encoded);
        }
Пример #16
0
    List <GamePiece> FindAllMatchValue(MatchValue mValue)
    {
        List <GamePiece> foundPieces = new List <GamePiece>();

        for (int i = 0; i < _width; i++)
        {
            for (int j = 0; j < _height; j++)
            {
                if (_allGamePieces[i, j] != null && _allGamePieces[i, j].MatchValue == mValue)
                {
                    foundPieces.Add(_allGamePieces[i, j]);
                }
            }
        }
        return(foundPieces);
    }
        public override void ExecuteCmdlet()
        {
            ValidateArguments();

            var matchCondition = new PSMatchCondition
            {
                MatchVariable    = MatchVariable,
                MatchValue       = MatchValue?.ToList(),
                NegateCondition  = !this.IsParameterBound(c => c.NegateCondition) ? false : NegateCondition,
                OperatorProperty = OperatorProperty,
                Selector         = Selector,
                Transform        = Transform?.ToList()
            };

            WriteObject(matchCondition);
        }
Пример #18
0
    private List <GamePiece> FindAllMatchValues(MatchValue mValue)
    {
        List <GamePiece> foundPieces = new List <GamePiece>();

        for (int i = 0; i < width; i++)
        {
            for (int j = 0; j < height; j++)
            {
                if (mAllGamePieces[i, j].matchValue == mValue)
                {
                    foundPieces.Add(mAllGamePieces[i, j]);
                }
            }
        }

        return(foundPieces);
    }
Пример #19
0
        public Func <DynamicTableEntity, bool> GetLinqFilter()
        {
            return(entity => {
                if (!entity.Properties.ContainsKey(DatabaseKeyName))
                {
                    return false;
                }

                var keyval = entity.Properties[DatabaseKeyName].StringValue;
                if (string.IsNullOrWhiteSpace(keyval))
                {
                    return false;
                }

                return IgnoreCase ? MatchValue.Equals(keyval, StringComparison.InvariantCultureIgnoreCase) : MatchValue == keyval;
            });
        }
Пример #20
0
    public void ChangeColor(GamePiece pieceToMatch)
    {
        SpriteRenderer rendererToChange = GetComponent <SpriteRenderer>();

        Color colorToMatch = Color.clear;

        if (pieceToMatch != null)
        {
            SpriteRenderer rendererToMatch = pieceToMatch.GetComponent <SpriteRenderer>();
            if (rendererToMatch != null && rendererToChange != null)
            {
                rendererToChange.color = rendererToMatch.color;
            }
            MatchValue = pieceToMatch.MatchValue;
        }
        #endregion
    }
Пример #21
0
    public void ChangeColor(Bubble bubbleToMatch)
    {
        SpriteRenderer rendererToChange = GetComponent <SpriteRenderer>();

        Color colorToMatch = Color.clear;

        if (bubbleToMatch != null)
        {
            SpriteRenderer rendererToMatch = bubbleToMatch.GetComponent <SpriteRenderer>();

            if (rendererToMatch != null && rendererToChange != null)
            {
                rendererToChange.color = rendererToMatch.color;
            }

            matchValue = bubbleToMatch.matchValue;
        }
    }
Пример #22
0
    public void ChangeSprite(GamePiece pieceToMatch)
    {
        //Sprite spriteToChange = null;

        SpriteRenderer rendererToChange = GetComponent <SpriteRenderer>();

        if (pieceToMatch != null)
        {
            SpriteRenderer rendererToMatch = pieceToMatch.GetComponent <SpriteRenderer>();

            if (rendererToMatch != null && rendererToChange != null)
            {
                rendererToChange.sprite = rendererToMatch.sprite;
            }

            matchValue = pieceToMatch.matchValue;
        }
    }
Пример #23
0
    ///<summary>Finds all GamePieces in 2D array with a specific match value</summary>
    public static List <GamePiece> FindAllMatchValue(GamePiece[,] allPieces, MatchValue mValue)
    {
        List <GamePiece> foundPieces = new List <GamePiece>();

        for (int i = 0; i < allPieces.GetLength(0); i++)
        {
            for (int j = 0; j < allPieces.GetLength(1); j++)
            {
                if (allPieces[i, j] != null)
                {
                    if (allPieces[i, j].MatchValue == mValue)
                    {
                        foundPieces.Add(allPieces[i, j]);
                    }
                }
            }
        }
        return(foundPieces);
    }
Пример #24
0
    private List <GamePiece> FindAllMatchValue(MatchValue matchValue)
    {
        List <GamePiece> foundPieces = new List <GamePiece>();

        for (int i = 0; i < width; i++)
        {
            for (int j = 0; j < height; j++)
            {
                if (gamePiecesArray[i, j] != null)
                {
                    if (gamePiecesArray[i, j].matchValue == matchValue)
                    {
                        foundPieces.Add(gamePiecesArray[i, j]);
                    }
                }
            }
        }
        return(foundPieces);
    }
Пример #25
0
 GameObject FindGamePieceByMatchValue(GameObject[] gamePiecePrefabs, MatchValue matchValue)
 {
     if (matchValue == MatchValue.None)
     {
         return(null);
     }
     foreach (GameObject pref in gamePiecePrefabs)
     {
         GamePiece gamePiece = pref.GetComponent <GamePiece>();
         if (gamePiece != null)
         {
             if (gamePiece.MatchValue == matchValue)
             {
                 return(pref);
             }
         }
     }
     return(null);
 }
Пример #26
0
    List <GamePiece> FindAllMatchValue(MatchValue mValue)
    {
        var foundPieces = new List <GamePiece>();

        for (int i = 0; i < width; i++)
        {
            for (int j = 0; j < height; j++)
            {
                if (m_allGamePieces[i, j] != null)
                {
                    if (m_allGamePieces[i, j].matchValue == mValue)
                    {
                        foundPieces.Add(m_allGamePieces[i, j]);
                    }
                }
            }
        }

        return(foundPieces);
    }
Пример #27
0
    public List <Bubble> FindAllMatchValue(MatchValue matchValue)
    {
        List <Bubble> foundBubbles = new List <Bubble>();

        for (int i = 0; i < m_board.width; i++)
        {
            for (int j = 0; j < m_board.height; j++)
            {
                if (m_board.allBubbles[i, j] != null)
                {
                    if (m_board.allBubbles[i, j].matchValue == matchValue)
                    {
                        foundBubbles.Add(m_board.allBubbles[i, j]);
                    }
                }
            }
        }

        return(foundBubbles);
    }
Пример #28
0
    private List <GamePiece> FindAllMatcheValue(MatchValue value)
    {
        List <GamePiece> foundPieces = new List <GamePiece>();

        for (int i = 0; i < width; i++)
        {
            for (int j = 0; j < height; j++)
            {
                if (allGamePieces[i, j] != null)
                {
                    if (allGamePieces[i, j].MatchVal == value)
                    {
                        foundPieces.Add(allGamePieces[i, j]);
                    }
                }
            }
        }

        return(foundPieces);
    }
Пример #29
0
    private GameObject FindGamePieceByMatchValue(GameObject[] gamePiecePrefabs, MatchValue matchValue)
    {
        if (matchValue == MatchValue.None)
        {
            return(null);
        }
        foreach (GameObject go in gamePiecePrefabs)
        {
            GamePiece piece = go.GetComponent <GamePiece>();

            if (piece != null)
            {
                if (piece.matchValue == matchValue)
                {
                    return(go);
                }
            }
        }
        return(null);
    }
Пример #30
0
    public void ChangeColor(GamePiece pieceToMatch)
    {
        SpriteRenderer rendererToChange = GetComponent <SpriteRenderer>();

        Color colorToMatch = Color.clear;

        if (pieceToMatch != null)
        {
            SpriteRenderer rendererToMatch = pieceToMatch.GetComponent <SpriteRenderer>();

            if (rendererToMatch != null && rendererToChange != null)
            {
                rendererToChange.color = rendererToMatch.color;
            }
            else
            {
                rendererToChange.color = colorToMatch;
            }

            matchVal = pieceToMatch.matchVal;
        }
    }