예제 #1
0
    // Update is called once per frame
    void Update()
    {
        switch (qs)
        {
        case queueState.preQueue:
        {
            PopUpPreQueue();
            break;
        }

        case queueState.queue:
        {
            GetComponent <SphereCollider>().radius = (0.64f * .5f);
            targetPos = Vector3.zero;
            RealignFromPrequeue();
            break;
        }

        case queueState.rdyQueue:
        {
            break;
        }

        case queueState.settling:
        {
            AlignToGrid();
            qs = queueState.idle;
            break;
        }

        case queueState.fusing:
        {
            Fuse();
            break;
        }

        case queueState.idle:
        {
            break;
        }

        case queueState.gameStart:
        {
            AlignToGrid();
            SpawnGameStart();         //growing to size, then switch to idle
            break;
        }

        default:
        {
            Debug.Log("Bad things happended");
            break;
        }
        }
    }
예제 #2
0
 void SpawnGameStart() //unique when game start
 {
     currentLerpTime += Time.deltaTime / gm.bubbleGrowTime;
     ReScale(currentLerpTime, Vector3.zero, initialSize);
     rb.constraints = RigidbodyConstraints.FreezeAll;
     if (transform.localScale == initialSize)
     {
         qs = queueState.idle;
         currentLerpTime = 0f;
     }
 }
예제 #3
0
    void PopUpPreQueue() //nur prequeue
    {
        currentLerpTime += Time.deltaTime / gm.bubbleGrowTime;
        Vector3 startSize  = transform.localScale;
        Vector3 targetSize = initialSize * preQueueScale;

        ReScale(currentLerpTime, startSize, targetSize);

        if (transform.localScale == targetSize)
        {
            qs = queueState.idle;
            currentLerpTime = 0f;
        }
    }
예제 #4
0
    void RealignFromPrequeue() //queue und Settle
    {
        currentLerpTime += Time.deltaTime / gm.bubbleGrowTime;

        Vector3 startSize = transform.localScale;

        ReScale(currentLerpTime, startSize, initialSize);

        RePosition(currentLerpTime);

        if (transform.localScale == initialSize && transform.localPosition == Vector3.zero)
        {
            GetComponent <SphereCollider>().isTrigger = false;
            currentLerpTime = 0f;
            qs = queueState.rdyQueue;
        }
    }
예제 #5
0
    private void OnCollisionEnter(Collision collision)
    {
        if (qs == queueState.rdyQueue)
        {
            if (collision.gameObject.layer == LayerMask.NameToLayer("Bubble"))
            {
                transform.parent = gm.bubbleManager.transform;
                rb.constraints   = RigidbodyConstraints.FreezeAll;

                Vector2[] pos = gm.AllEmptyNeighbours(gm.AllPossibleNeighbours(collision.gameObject.GetComponent <Bubble>().hexCoords));
                if (pos.Length == 1)
                {
                    hexCoords = pos[0];
                }
                else //check for closest match
                {
                    float mag = 100000f;
                    foreach (Vector2 p in pos)
                    {
                        float dist = Mathf.Abs(Vector3.Magnitude(gm.convertHexToPixel(p) - transform.position));
                        if (dist < mag)
                        {
                            mag       = dist;
                            hexCoords = p;
                        }
                    }
                }
                gm.bubbleArray.Add(hexCoords, this);
                gm.newestBubble = this;
                GetComponent <SphereCollider>().radius = 0.64f;
                qs = queueState.settling;
                gm.queueForCleanup = true;
                collided           = true;
            }
        }
    }