public BugColor GetRandomSecondaryColor()
    {
        System.Array bugColors = System.Enum.GetValues(typeof(BugColor));
        BugColor     bugColor  = (BugColor)bugColors.GetValue(UnityEngine.Random.Range(3, 5));

        return(bugColor);
    }
    public BugColor GetRandomColor()
    {
        System.Array bugColors = System.Enum.GetValues(typeof(BugColor));
        BugColor     bugColor  = (BugColor)bugColors.GetValue(UnityEngine.Random.Range(0, bugColors.Length - 1));

        return(bugColor);
    }
    public void Paint(BugColor colorToPaint)
    {
        Sprite colorSprite = BugColoring.Instance.GetSpriteByType(colorToPaint, out rbgColor);

        if (colorSprite != null)
        {
            bugColor = colorToPaint;
            bugCtrl.spriteRender.sprite = colorSprite;
            PlayPaintEffect();
        }
    }
    public void TryPaint(BugColor colorToPaint)
    {
        if (!readyToPaint)
        {
            return;
        }

        if (currentColor == BugColor.White)
        {
            currentBug.Paint(colorToPaint);
        }
        else if (currentColor == BugColor.Red)
        {
            if (colorToPaint == BugColor.Blue && targetColor == BugColor.Purple)
            {
                currentBug.Paint(BugColor.Purple);
            }
            else
            {
                currentBug.Paint(colorToPaint);
            }
        }
        else if (currentColor == BugColor.Green)
        {
            if (colorToPaint == BugColor.Blue && targetColor == BugColor.Cyan)
            {
                currentBug.Paint(BugColor.Cyan);
            }
            else
            {
                currentBug.Paint(colorToPaint);
            }
        }
        else if (currentColor == BugColor.Blue)
        {
            if (colorToPaint == BugColor.Red && targetColor == BugColor.Purple)
            {
                currentBug.Paint(BugColor.Purple);
            }
            else if (colorToPaint == BugColor.Green && targetColor == BugColor.Cyan)
            {
                currentBug.Paint(BugColor.Cyan);
            }
            else
            {
                currentBug.Paint(colorToPaint);
            }
        }

        brushAnimator.SetTrigger("IsBrushing");
        currentColor = currentBug.bugColor;
        CheckMatch();
    }
Exemple #5
0
 public void getBugTexture(BugColor color)
 {
     this.bugcolor = color;
        switch (color){
        case BugColor.Pink :
            BUG = SquatBugsMainGame.GetInstance().game.Content.Load<Texture2D>("Bugs/lieveheers_roze_sprite");
            break;
        case BugColor.Blue:
            BUG = SquatBugsMainGame.GetInstance().game.Content.Load<Texture2D>("Bugs/lieveheers_blauw_sprite");
            break;
        case BugColor.Green:
            BUG = SquatBugsMainGame.GetInstance().game.Content.Load<Texture2D>("Bugs/lieveheers_geel_sprite");
            break;
        }
 }
Exemple #6
0
 public FriendlyBug(Vector2 speed, int score, double changedirectiontimer, Vector2 location,BugColor color)
 {
     getBugTexture(color);
     this.Speed = speed;
     this.Score = score;
     this.NrOfFrames = 3;
     //this.RotationCorrection = -.5f;
     this.RotationCorrection = -1.7f;
     this.ChangeDirectionTimer = changedirectiontimer;
     this.scale = new Vector2(0.35f, 0.35f);
     this.location = location;
     this.EndLocation = BugManager.GetInstance().GetRandomLocation();
     this.FadeTime = 1500;
     this.FadeTimer = FadeTime;
 }
    IEnumerator SpawnBug()
    {
        yield return(new WaitForSeconds(0.2f));

        readyToPaint = true;
        currentIdx++;
        int childIdx = (int)targetBugs[currentIdx].bugColor;

        activeBugSprite = targetBugSprites[childIdx];
        activeBugSprite.SetActive(true);

        targetColor  = targetBugs[currentIdx].bugColor;
        currentBug   = queueBugs[currentIdx];
        currentColor = currentBug.bugColor;
    }
    public Sprite GetSpriteByType(BugColor bugColor, out Color color)
    {
        for (int i = 0; i < bugSprites.Count; i++)
        {
            if (bugSprites[i].bugColor == bugColor)
            {
                color = bugSprites[i].color;
                return(bugSprites[i].bugSprite);
            }
        }

        Debug.LogWarning("Sprite not found");
        color = bugSprites[0].color;
        return(null);
    }
 private void Update()
 {
     if (Input.GetKeyDown(KeyCode.A))
     {
         ColorWheel.Instance.TrySpinRight();
     }
     else if (Input.GetKeyDown(KeyCode.D))
     {
         ColorWheel.Instance.TrySpinLeft();
     }
     else if (Input.GetKeyDown(KeyCode.J))
     {
         BugColor colorToPaint = ColorWheel.Instance.GetCurrentColor();
         PaintQueueManager.Instance.TryPaint(colorToPaint);
     }
 }
Exemple #10
0
    public void GeneratePopEffect(float x, float y, BugColor bugColor)
    {
        impulseSource.GenerateImpulse();
        if (popEffectPrefab)
        {
            var effect    = Instantiate(popEffectPrefab, new Vector3(x, y, 0), Quaternion.identity);
            var particles = effect.GetChild(0)?.GetComponent <ParticleSystem>();
            if (particles)
            {
                var color = Color.white;
                switch (bugColor)
                {
                case BugColor.Blue:
                    color = new Color(0.0f, 0.3f, 1f, 1f);
                    break;

                case BugColor.Green:
                    color = Color.green;
                    break;

                case BugColor.Purple:
                    color = Color.magenta;
                    break;

                case BugColor.Red:
                    color = Color.red;
                    break;

                case BugColor.Yellow:
                    color = Color.yellow;
                    break;
                }
                var main = particles.main;
                main.startColor = new ParticleSystem.MinMaxGradient(color);
            }
        }
    }
Exemple #11
0
 public BugData(BugColor bugColor)
 {
     this.bugColor = bugColor;
 }
Exemple #12
0
        protected override void OnUpdate()
        {
            ComponentDataFromEntity <BugComponent> bugComponent = GetComponentDataFromEntity <BugComponent>();
            BufferFromEntity <EntityBufferElement> entityBuffer = GetBufferFromEntity <EntityBufferElement>();

            var time = Time.DeltaTime;

            timeSinceStart += time;
            var random = new Random((uint)(timeSinceStart * 1000f));

            //Recursive method of finding chains of one color, some kind of flood fill
            void FindChainRec(
                Entity entity,
                BugComponent ball,
                BugColor neededColor,
                DynamicBuffer <EntityBufferElement> adjacentEntities,
                NativeHashMap <Entity, bool> chainMap)
            {
                if (!chainMap.ContainsKey(entity) && ball.Color == neededColor)
                {
                    chainMap.Add(entity, true);
                }

                for (int i = 0; i < adjacentEntities.Length; i++)
                {
                    var adjacentEntity = adjacentEntities[i].Value;
                    var adjacentBall   = bugComponent[adjacentEntity];
                    if (!chainMap.ContainsKey(adjacentEntity) && adjacentBall.Color == neededColor)
                    {
                        chainMap.Add(adjacentEntity, true);
                        var nextBall     = bugComponent[adjacentEntity];
                        var nextAdjacent = entityBuffer[adjacentEntity];
                        FindChainRec(adjacentEntity, nextBall, neededColor, nextAdjacent, chainMap);
                    }
                }
            }

            var minChainSize  = minimumChainSize;
            var commandBuffer = barrier.CreateCommandBuffer().ToConcurrent();

            Dependency = Entities.ForEach((Entity entity, int nativeThreadIndex, int entityInQueryIndex,
                                           in BugComponent bug, in DynamicBuffer <EntityBufferElement> adjacentEntities, in ChainMarkComponent mark) =>
            {
                commandBuffer.RemoveComponent <ChainMarkComponent>(nativeThreadIndex, entity);
                BugColor neededColor = mark.NeededColor;

                //Should be HashSet as we don't need value here, but there is no NativeHashSet at the moment
                NativeHashMap <Entity, bool> chainMap = new NativeHashMap <Entity, bool>(100, Allocator.Temp);
                FindChainRec(entity, bug, neededColor, adjacentEntities, chainMap);
                var keys = chainMap.GetKeyArray(Allocator.Temp);
                if (keys.Length >= minChainSize)
                {
                    //Trigger spawning additional bugs
                    commandBuffer.AddComponent <SpawnMarkComponent>(nativeThreadIndex, entity);
                    commandBuffer.SetComponent(nativeThreadIndex, entity, new SpawnMarkComponent
                    {
                        Count = keys.Length
                    });

                    for (var i = 0; i < keys.Length; i++)
                    {
                        //Remove popped bugs with delay
                        commandBuffer.AddComponent <RemoveMarkComponent>(nativeThreadIndex, keys[i]);
                        commandBuffer.SetComponent(nativeThreadIndex, keys[i], new RemoveMarkComponent
                        {
                            DelayMs = random.NextInt(0, 20)
                        });
                    }
                }
                chainMap.Dispose();
            })