Пример #1
0
    private void OnTriggerEnter(Collider other)
    {
        ColorBall tempColorBall = other.gameObject.GetComponent <ColorBall>();

        if (tempColorBall)
        {
            // Don't case equal for now lol
            if ((int)type > (int)tempColorBall.type)
            {
                type      = GeneralTable.Combine(type, tempColorBall.type);
                BallColor = GeneralTable.GetColor(type);

                GamePlayManager.Instance.centerPoint.RemoveEstimateColorBallNum();
            }
            else
            {
                Destroy(this.gameObject);
            }
        }
        CenterPoint tempCenterPoint = other.gameObject.GetComponent <CenterPoint>();

        if (tempCenterPoint)
        {
            nextCenterPoint.match(type);
            ballCollider.enabled = false;
        }
    }
Пример #2
0
    private void CreateBall(GameEntity track, GameEntity chain, float distance)
    {
        // TODO: if will error - replace zero to some more useful
        //var pathCreator           // continue point
        Transform ball      = pool.RealeseObject(Vector3.zero, Quaternion.identity, normalScale).transform;
        ColorBall colorType = track.randomizer.value.GetRandomColorType();

        GameEntity entityBall = _contexts.game.CreateEntity();

        entityBall.AddBallId(Extensions.BallId);
        entityBall.AddDistanceBall(distance);
        entityBall.AddTransform(ball);
        entityBall.AddSprite(ball.GetComponent <SpriteRenderer>());
        entityBall.AddColor(colorType);
        entityBall.AddParentChainId(chain.chainId.value);

        ball.tag = Constants.BALL_TAG;
        ball.gameObject.Link(entityBall, _contexts.game);

        if (_contexts.global.isDebugAccess)
        {
            _contexts.manage.CreateEntity()
            .AddLogMessage($" ___ Created new ball in chain: {entityBall.ToString()}", TypeLogMessage.Trace, false, GetType());
        }
    }
Пример #3
0
    public void ReplaceColor(ColorBall newValue)
    {
        var index     = GameComponentsLookup.Color;
        var component = (ColorComponent)CreateComponent(index, typeof(ColorComponent));

        component.value = newValue;
        ReplaceComponent(index, component);
    }
 private void IncrementColorRecords(Dictionary <ColorBall, int> records, ColorBall color)
 {
     if (records.ContainsKey(color))
     {
         records[color]++;
     }
     else
     {
         records.Add(color, 1);
     }
 }
Пример #5
0
    public static Color ConvertToColor(ColorBall colorType)
    {
        foreach (var info in colorsInfo)
        {
            if (info.type == colorType)
            {
                return(info.color);
            }
        }

        Debug.Log($"Color type({colorType}) is not found in colors collection");
        return(Color.white);
    }
Пример #6
0
    private void RandomNewSeries()
    {
        // TODO: In future, change choosing logic to more complicated (based on existing colors and its quantity)
        int newColorIndex = Random.Range(0, colorsInfo.Length);

        // TODO: Maybe replace recursion to do-while loop
        if (newColorIndex == (int)currentColor)
        {
            RandomNewSeries();
            return;
        }

        currentColor  = (ColorBall)newColorIndex;
        currentSeries = Random.Range(minLengthSeries, maxLengthSeries + 1);
    }
    private void DecrementColorRecords(Dictionary <ColorBall, int> records, ColorBall color)
    {
        if (records.ContainsKey(color))
        {
            records[color]--;

            if (records[color] == 0)
            {
                records.Remove(color);
            }
        }
        else
        {
            Debug.Log($"Reducing ball number with {color}, that doesn't exist in records");
        }
    }
    private void PassBallsWithSameColor(List <GameEntity> balls, ColorBall insertedColor, int insertedIndex, Action <GameEntity> action)
    {
        for (int i = insertedIndex; i < balls.Count; i++)
        {
            if (balls[i].color.value != insertedColor)
            {
                break;
            }

            action(balls[i]);
        }

        for (int i = insertedIndex - 1; i >= 0; i--)
        {
            if (balls[i].color.value != insertedColor)
            {
                break;
            }

            action(balls[i]);
        }
    }
Пример #9
0
 /// <summary>
 /// 自身の隣接しているボールをセットする関数
 /// </summary>
 /// <param name="setColorBall">セットするボール</param>
 /// <param name="setType">セットするタイプ</param>
 public void SetAdjoiningBalls(ColorBall setColorBall, TheTypeOfBowlToExamine setType)
 {
     adjoiningBalls[(int)setType] = setColorBall;
 }
Пример #10
0
 public void changeColor()
 {
     current = ColorBall.randomColor();
     b       = new SolidBrush(current);
 }
Пример #11
0
 public void AddRolledBall(ColorBall rolledBall)
 {
     RolledColorBallsCount++;
     OnBallAdded?.Invoke(rolledBall.Icon);
 }