コード例 #1
0
    private Color EffectColor(GemColor gemColor)
    {
        gemColor = gemColor - 1;
        Color tempColor = new Color();

        switch (gemColor)
        {
        case GemColor.Black:
            tempColor = Color.gray;
            break;

        case GemColor.Green:
            tempColor = Color.green;
            break;

        case GemColor.Red:
            tempColor = Color.red;
            break;

        case GemColor.Sky:
            tempColor = new Color(0.31f, 0.73f, 0.87f);
            break;

        case GemColor.Yellow:
            tempColor = Color.yellow;
            break;
        }
        return(tempColor);
    }
 public void AddGem(GemColor type)
 {
     collectibleIcon.sprite = gemIcons[(int)type].sprite;
     animator.SetTrigger("collectibleup");
     gems[type] = true;
     gemIcons[(int)type].gameObject.SetActive(true);
 }
コード例 #3
0
    public void AddGem(GemColor color)
    {
        switch (color)
        {
        case GemColor.Red:
            _red = true;
            break;

        case GemColor.Green:
            _green = true;
            break;

        case GemColor.Blue:
            _blue = true;
            break;

        default:
            throw new InvalidOperationException("Unrecognized gem color");
        }

        if (_red && _green && _blue)
        {
            StartCoroutine(flowController.EndGame());
        }
    }
コード例 #4
0
    public void SetAnimation(GemColor gemColor, int gemCount, bool isTopPlayer)
    {
        Debug.Log(gemColor);
        switch (gemColor)
        {
        case GemColor.Blue:         //RECOVER
            ghc.OnPlayerRecover(isTopPlayer);
            break;

        case GemColor.Red:          //ATTACK 01
            ghc.OnPlayerAttack(isTopPlayer, TYPE_01);
            break;

        case GemColor.Purple:       //ATTACK 02
            ghc.OnPlayerAttack(isTopPlayer, TYPE_02);
            break;

        case GemColor.Green:        //DEFENSE 01
            ghc.OnPlayerDefense(isTopPlayer, TYPE_01);
            break;

        case GemColor.Yellow:       //DEFENSE 02
            ghc.OnPlayerDefense(isTopPlayer, TYPE_02);
            break;

        case GemColor.Empty:
        case GemColor.COUNT:
        case GemColor.INVALID:
        default:
            Debug.Log("INVALID GEM");
            break;
        }
    }
コード例 #5
0
ファイル: Gem.cs プロジェクト: Oskiii/Match3
    private void OnEnable()
    {
        KeyValuePair <GemColor, Color32> randomGemColor =
            _gemColorValues.ElementAt(Random.Range(0, _gemColorValues.Keys.Count));

        _visuals.color = randomGemColor.Value;
        Color          = randomGemColor.Key;
    }
コード例 #6
0
ファイル: Gem.cs プロジェクト: Soothsilver/megajewel
 public Gem(GemColor gemColor, Bitmap bitmap, int x = 0, int y = 0)
 {
     Bitmap = bitmap;
     X = x;
     Y = y;
     GemColor = gemColor;
     Histograms = Histograms.Calculate(bitmap);
 }
コード例 #7
0
ファイル: Gem.cs プロジェクト: Soothsilver/megajewel
 public Gem(GemColor gemColor, Bitmap bitmap, int x = 0, int y = 0)
 {
     Bitmap     = bitmap;
     X          = x;
     Y          = y;
     GemColor   = gemColor;
     Histograms = Histograms.Calculate(bitmap);
 }
コード例 #8
0
 public Gem(GameObject gameObject, GemColor color)
 {
     GameObj    = gameObject;
     Color      = color;
     IsActing   = false;
     LocalScale = GameObj.transform.localScale;
     ColorIndex = GetColorIndex(Color);
 }
コード例 #9
0
ファイル: GemColor.cs プロジェクト: HL971/Gemstone
        internal static string ColorString(this GemColor gem)
        {
            switch (gem)
            {
            case GemColor.UNDEFINED:
                return(null);

            default:
                return(gem.ToString());
            }
        }
コード例 #10
0
        public Sprite GetSpriteConfig(GemColor gemColor)
        {
            foreach (var spriteConfig in gemSpriteConfigs)
            {
                if (spriteConfig.Color == gemColor)
                {
                    return(spriteConfig.Sprite);
                }
            }

            return(null);
        }
コード例 #11
0
    public string RandomGetGemList()
    {
        int random = Random.Range(zero, gemLevelList.Count);

        randomLevel = gemLevelList[random];
        int randomColor = Random.Range(0, colorKinds);

        GemColor color = (GemColor)randomColor;

        string name = randomLevel.ToDesc() + color.ToDesc();

        return(name);
    }
コード例 #12
0
        public static string GetGemImage(int size, GemColor color)
        {
            string result;

            if (size > 0 && size <= 299)
            {
                result = $"pack://application:,,,/Resources/Images/Gems/{color}/{color}ClassOne.png";
            }
            else if (size > 299 && size <= 999)
            {
                result = $"pack://application:,,,/Resources/Images/Gems/{color}/{color}ClassTwo.png";
            }
            else if (size > 999 && size <= 2999)
            {
                result = $"pack://application:,,,/Resources/Images/Gems/{color}/{color}ClassThree.png";
            }
            else if (size > 2999 && size <= 9999)
            {
                result = $"pack://application:,,,/Resources/Images/Gems/{color}/{color}ClassFour.png";
            }
            else if (size > 9999 && size <= 29999)
            {
                result = $"pack://application:,,,/Resources/Images/Gems/{color}/{color}ClassFive.png";
            }
            else if (size > 29999 && size <= 99999)
            {
                result = $"pack://application:,,,/Resources/Images/Gems/{color}/{color}ClassSix.png";
            }
            else if (size > 99999 && size <= 299999)
            {
                result = $"pack://application:,,,/Resources/Images/Gems/{color}/{color}ClassSeven.png";
            }
            else if (size > 299999 && size <= Constants.Constants.GemSizes.SEMI_PERFECT)
            {
                result = $"pack://application:,,,/Resources/Images/Gems/{color}/{color}ClassEight.png";
            }
            else if (size > Constants.Constants.GemSizes.SEMI_PERFECT && size < Constants.Constants.GemSizes.PERFECT)
            {
                result = $"pack://application:,,,/Resources/Images/Gems/{color}/{color}ClassNine.png";
            }
            else if (size == Constants.Constants.GemSizes.PERFECT)
            {
                result = "pack://application:,,,/Resources/Images/Gems/Perfect/Perfect.png";
            }
            else
            {
                throw new InvalidOperationException($"Invalid gem size: {size}");
            }

            return(result);
        }
コード例 #13
0
    public void ExplodeGems(BackToBackCount gemCount)
    {
        if (gemCount.HasEnoughHorizontalToMatch())
        {
            // TODO - collect type of gems to use as power
            foreach (Gem gem in gemCount.horizontalGems)
            {
                if (gem.gemTypeSO.GemType != GemType.Empty)
                {
                    Instantiate(gemExplosion, gem.transform.position, gem.transform.rotation);
                    count++;
                    if (color != gem.gemTypeSO.GemColor)
                    {
                        color = gem.gemTypeSO.GemColor;
                    }
                }
                GemTypeSO gemTypeSO = new GemTypeSO();
                gemTypeSO.GemType  = GemType.Empty;
                gemTypeSO.GemColor = GemColor.Empty;
                gem.SetType(gemTypeSO);
            }
        }
        if (gemCount.HasEnoughVerticalToMatch())
        {
            // TODO - collect type of gems to use as power
            foreach (Gem gem in gemCount.verticalGems)
            {
                if (gem.gemTypeSO.GemType != GemType.Empty)
                {
                    Instantiate(gemExplosion, gem.transform.position, gem.transform.rotation);
                    count++;
                    if (color != gem.gemTypeSO.GemColor)
                    {
                        color = gem.gemTypeSO.GemColor;
                    }
                }
                GemTypeSO gemTypeSO = new GemTypeSO();
                gemTypeSO.GemType  = GemType.Empty;
                gemTypeSO.GemColor = GemColor.Empty;
                gem.SetType(gemTypeSO);
            }
        }

        if (count > 0)
        {
            PlayerPowerups(count, color);
            count = 0;
        }
    }
コード例 #14
0
        public static Entity CreateGem(GemColor gemColor, float3 originPosition, int2 boardPosition)
        {
            var entity = EntityManager.CreateEntity(GemArchetype);

            EntityManager.SetComponentData(entity, new Translation {
                Value = new float3(originPosition.x, originPosition.y, 0)
            });
            EntityManager.SetComponentData(entity, new BoardPositionComponent {
                Position = boardPosition
            });
            EntityManager.SetComponentData(entity, new GemComponent {
                Color = gemColor
            });

            return(entity);
        }
コード例 #15
0
    private List <Gem> FindMatchesInColumn(int x)
    {
        var matchGems  = new List <Gem>();
        var columnGems = new List <Gem>();

        // Get gems in row
        for (var y = 0; y < Rows; y++)
        {
            columnGems.Add(GemsOnBoard[x, y]);
        }

        // No need to check last 2 because they can't start matches
        for (var y = 0; y < columnGems.Count - 2; y++)
        {
            Gem current = columnGems[y];
            Gem next1   = columnGems[y + 1];
            Gem next2   = columnGems[y + 2];

            if (current == null)
            {
                continue;
            }

            // Do all 3 gems' colors match?
            GemColor matchColor = current.Color;
            bool     foundMatch = matchColor == next1?.Color && matchColor == next2?.Color;
            if (foundMatch)
            {
                var match = new List <Gem> {
                    current, next1, next2
                };

                // Look UP until gem color doesn't match. Add all found to match list
                var currentIndex = 3;
                while (y + currentIndex < columnGems.Count && columnGems[y + currentIndex]?.Color == current.Color)
                {
                    match.Add(columnGems[y + currentIndex]);
                    currentIndex++;
                }
                matchGems.AddRange(match);
            }
        }

        return(matchGems);
    }
コード例 #16
0
    private List <Gem> FindMatchesInRow(int y)
    {
        var matchGems = new List <Gem>();
        var rowGems   = new List <Gem>();

        // Get gems in row
        for (var x = 0; x < Columns; x++)
        {
            rowGems.Add(GemsOnBoard[x, y]);
        }

        // No need to check last 2 because they can't start matches
        for (var x = 0; x < rowGems.Count - 2; x++)
        {
            Gem current = rowGems[x];
            Gem next1   = rowGems[x + 1];
            Gem next2   = rowGems[x + 2];

            if (current == null)
            {
                continue;
            }

            // Do all 3 gems' colors match?
            GemColor matchColor = current.Color;
            bool     foundMatch = matchColor == next1?.Color && matchColor == next2?.Color;
            if (foundMatch)
            {
                var match = new List <Gem> {
                    current, next1, next2
                };

                // Look RIGHT until gem color doesn't match. Add all found to match list
                var currentIndex = 3;
                while (x + currentIndex < rowGems.Count && rowGems[x + currentIndex]?.Color == current.Color)
                {
                    match.Add(rowGems[x + currentIndex]);
                    currentIndex++;
                }
                matchGems.AddRange(match);
            }
        }

        return(matchGems);
    }
コード例 #17
0
    void FixInitialBoard()
    {
        for (int x = 0, y = 0; x < boardNumCells.x; x++, y = 0)
        {
            for (; y < boardNumCells.y; y++)
            {
                Gem             currentGem = gemsTable[x, y];
                BackToBackCount cellCount  = backToBackCountOnIndex(currentGem.GetIndex(), currentGem.gemTypeSO.GemColor);
                if (cellCount.HasEnoughToMatch())
                {
                    int        currentIndex      = 0;
                    GemColor[] neighboursColours = new GemColor[4];
                    if (x != boardNumCells.x - 1)
                    {
                        Vector2Int newIndex = currentGem.GetIndex() + Vector2Int.right;
                        neighboursColours[currentIndex++] = gemsTable[newIndex.x, newIndex.y].gemTypeSO.GemColor;
                    }
                    if (x != 0)
                    {
                        Vector2Int newIndex = currentGem.GetIndex() + Vector2Int.left;
                        neighboursColours[currentIndex++] = gemsTable[newIndex.x, newIndex.y].gemTypeSO.GemColor;
                    }
                    if (y != boardNumCells.y - 1)
                    {
                        Vector2Int newIndex = currentGem.GetIndex() + Vector2Int.up;
                        neighboursColours[currentIndex++] = gemsTable[newIndex.x, newIndex.y].gemTypeSO.GemColor;
                    }
                    if (y != 0)
                    {
                        Vector2Int newIndex = currentGem.GetIndex() + Vector2Int.down;
                        neighboursColours[currentIndex++] = gemsTable[newIndex.x, newIndex.y].gemTypeSO.GemColor;
                    }

                    GemColor gemColor = GemColor.Blue;

                    while (Array.Exists(neighboursColours, color => color == gemColor))
                    {
                        gemColor++;
                    }
                    currentGem.SetType(gemsInfo.Info[(int)gemColor - 1]);
                }
            }
        }
    }
コード例 #18
0
        public static string GetPotionResult(GemColor color1, GemColor color2, GemColor color3)
        {
            if (color1 != color2 || color2 != color3 || color3 != color1)
            {
                return(null);
            }

            string result;

            switch (color1)
            {
            case GemColor.Blue:
                result = "pack://application:,,,/Resources/Images/Potions/GangOfThieves.png";

                break;

            case GemColor.Green:
                result = "pack://application:,,,/Resources/Images/Potions/SlowMotion.png";

                break;

            case GemColor.Purple:
                result = "pack://application:,,,/Resources/Images/Potions/Ghost.png";

                break;

            case GemColor.Red:
                result = "pack://application:,,,/Resources/Images/Potions/DisableTrap.png";

                break;

            case GemColor.Yellow:
                result = "pack://application:,,,/Resources/Images/Potions/DoubleGold.png";

                break;

            default:

                throw new InvalidOperationException($"Invalid gem color: {color1}");
            }

            return(result);
        }
コード例 #19
0
        private int CountSameColorMatchHorizontal(int startX, int startY, GemColor gemColor)
        {
            int count = 0;

            for (int x = startX; x < boardWidth; x++)
            {
                var nextEntity   = board[x][startY];
                var nextGemColor = entityManager.GetComponentData <GemComponent>(nextEntity).Color;
                if (gemColor == nextGemColor)
                {
                    count++;
                }
                else
                {
                    break;
                }
            }

            return(count);
        }
コード例 #20
0
        private int CountSameColorMatchVertical(int startX, int startY, GemColor gemColor)
        {
            int count = 0;

            for (int y = startY; y < boardHeight; y++)
            {
                var nextEntity   = board[startX][y];
                var nextGemColor = entityManager.GetComponentData <GemComponent>(nextEntity).Color;
                if (gemColor == nextGemColor)
                {
                    count++;
                }
                else
                {
                    break;
                }
            }

            return(count);
        }
コード例 #21
0
 private int GetColorIndex(GemColor color)
 {
     if (color.Equals(GemColor.BLUE))
     {
         return(0);
     }
     if (color.Equals(GemColor.DIAMOND))
     {
         return(1);
     }
     if (color.Equals(GemColor.GREEN))
     {
         return(2);
     }
     if (color.Equals(GemColor.MAGENTA))
     {
         return(3);
     }
     if (color.Equals(GemColor.ORANGE))
     {
         return(4);
     }
     if (color.Equals(GemColor.RED))
     {
         return(5);
     }
     if (color.Equals(GemColor.WHITE))
     {
         return(6);
     }
     if (color.Equals(GemColor.YELLOW))
     {
         return(7);
     }
     return(-1);
 }
コード例 #22
0
 public bool CanBeMatchedWith(GemColor gemColor)
 {
     return(gemColor == gemTypeSO.GemColor);
 }
コード例 #23
0
ファイル: GemDefinitions.cs プロジェクト: mrsheen/bbot
        public static Color GetDisplayColorForGem(GemColor gemColor)
        {
            Color displayColor = Color.Black;

            switch (gemColor)
            {
                case GemColor.Green:
                    displayColor = Color.DarkGreen;
                    break;
                case GemColor.Blue:
                    displayColor = Color.DarkBlue;
                    break;
                case GemColor.Orange:
                    displayColor = Color.DarkOrange;
                    break;
                case GemColor.Purple:
                    displayColor = Color.Purple;
                    break;
                case GemColor.Red:
                    displayColor = Color.DarkRed;
                    break;
                case GemColor.White:
                    displayColor = Color.LightGray;
                    break;
                case GemColor.Yellow:
                    displayColor = Color.LemonChiffon;
                    break;
            }

            return displayColor;
        }
コード例 #24
0
ファイル: Gem.cs プロジェクト: doskir/Bejeweled3Bot
 public Gem(GemColor color,GemType type)
 {
     Color = color;
     Type = type;
 }
コード例 #25
0
 public void PlayerPowerups(int gemCount, GemColor gemColor)
 {
     Debug.Log(gemCount);
     Debug.Log(gemColor);
     powerupController.SetAnimation(gemColor, gemCount, !isMyTurn);
 }
コード例 #26
0
 protected string GetGemDescription()
 {
     return("Color of this gem is : "
            + GemColor.ToString());
 }
コード例 #27
0
    public BackToBackCount backToBackCountOnIndex(Vector2Int index, GemColor gemColor)
    {
        BackToBackCount count = new BackToBackCount();

        Gem rootGem = gemsTable[index.x, index.y];

        if (rootGem != null)
        {
            count.horizontalGems.Add(rootGem);
            count.verticalGems.Add(rootGem);
        }

        // Count left
        for (int x = index.x - 1; x >= 0; x--)
        {
            Gem gem = gemsTable[x, index.y];
            if (gem == null || !gem.CanBeMatchedWith(gemColor))
            {
                break;
            }
            else
            {
                count.horizontalGems.Add(gem);
            }
        }

        // Count right
        for (int x = index.x + 1; x < boardNumCells.x; x++)
        {
            Gem gem = gemsTable[x, index.y];
            if (gem == null || !gem.CanBeMatchedWith(gemColor))
            {
                break;
            }
            else
            {
                count.horizontalGems.Add(gem);
            }
        }

        // Count up
        for (int y = index.y + 1; y < boardNumCells.y; y++)
        {
            Gem gem = gemsTable[index.x, y];
            if (gem == null || !gem.CanBeMatchedWith(gemColor))
            {
                break;
            }
            else
            {
                count.verticalGems.Add(gem);
            }
        }

        // Count down
        for (int y = index.y - 1; y >= 0; y--)
        {
            Gem gem = gemsTable[index.x, y];
            if (gem == null || !gem.CanBeMatchedWith(gemColor))
            {
                break;
            }
            else
            {
                count.verticalGems.Add(gem);
            }
        }

        return(count);
    }
コード例 #28
0
ファイル: ColorGem.cs プロジェクト: Franziskus/DiamondJam
 /// <summary>
 /// Initializes a new instance of the <see cref="DiamondJam.Control.Gems.ColorGem"/> class.
 /// </summary>
 /// <param name="c">Color of this Gem (<see cref="DiamondJam.Control.Gems.ColorGem.GemColor"/> enum).</param>
 public ColorGem(GemColor c)
 {
     this.color = c;
 }
 public Runestone(ItemWeight itemWeight, GemColor color) : base(itemWeight)
 {
     this.color = color;
 }
コード例 #30
0
ファイル: IcedColorGem.cs プロジェクト: Franziskus/DiamondJam
 /// <summary>
 /// Initializes a new instance of the <see cref="DiamondJam.Control.Gems.IcedColorGem"/> class.
 /// </summary>
 /// <param name="c">color of this gem</param>
 public IcedColorGem(GemColor c)
     : base(c)
 {
 }