Пример #1
0
    void CreateDotOnCircle()
    {
        Time.timeScale = 1;


        GameObject prefab = this.DotPrefab;
        Quaternion rot    = prefab.transform.rotation;

        Vector3   posTOP    = new Vector3(0, positionTouchBorderTOP, 0);
        Transform parentTOP = CircleBorderTOP;


        float numberTOP = numberDotsOnCircle * ratioNombreDotsOnCircleTop;


        for (int i = 0; i < (int)numberTOP; i++)
        {
            CircleTOP.rotation = Quaternion.Euler(new Vector3(0, 0, i * 360f / (int)numberTOP));

            DotManager dm = InstantiateDot(posTOP, rot, parentTOP);

            dm.ActivateLine(dm.transform.position, dm.transform.parent);
        }

        Vector3 posBOTTOM = new Vector3(0, positionTouchBorderBOTTOM, 0);

        float numberBOTTOM = numberDotsOnCircle * ratioNombreDotsOnCircleBottom;

        for (int i = 0; i < (int)numberBOTTOM; i++)
        {
            CircleBOTTOM.rotation = Quaternion.Euler(new Vector3(0, 0, i * 360f / (int)numberBOTTOM));

            DotManager dm = InstantiateDot(posBOTTOM, rot, CircleBorderBOTTOM);

            dm.ActivateLine(dm.transform.position, dm.transform.parent);
        }
    }
Пример #2
0
    /// <summary>
    /// All the game level creation logic. We will create the current level.
    /// </summary>
    public void CreateGame(int level)
    {
        if (sequence != null)
        {
            sequence.Kill(false);
        }

        if (sequenceDOT == null)
        {
            ResetPosition();
            SequenceDOTLogic();
        }

        canvasManager.ButtonLogic();

        DOTween.Kill(CircleBorder);

        DOTween.Kill(CircleBorder);


        CancelInvoke();

        StopAllCoroutines();

        isGameOver = false;
        success    = false;

        Level = Util.GetLastLevelPlayed();

        Level l = levelManager.GetLevel(Level);

        numberDotsOnCircle = l.numberDotsOnCircle;

        SizeRayonRatio    = l.sizeRayonRation;
        rotateCircleDelay = l.rotateDelay;
        easeType          = l.rotateEaseType;
        loopType          = l.rotateLoopType;

        positionTouchBorder = height * SizeRayonRatio;

        canvasManager.ButtonLogic();

        PLAYER.localRotation = Quaternion.identity;

        Time.timeScale = 1;

        Application.targetFrameRate = 60;

        GC.Collect();

        PLAYER.localRotation = Quaternion.identity;


        PLAYER.localScale = new Vector3(-rotateDOTVector.z, 1, 1);

        PLAYER.localRotation = Quaternion.identity;

        spriteDotGameOverZoom.transform.DOScale(Vector3.zero, 0.5f);

        guyAnim.DoWalk();
        this.Level = level;

        Camera.main.orthographicSize   = cameraSize;
        Camera.main.transform.position = new Vector3(0, 0, -10);

        StopAllCoroutines();

        CircleCenterSprite.color = constant.SquareColor;

        poolSystem.DespawnAll();



        Camera.main.transform.position = new Vector3(0, 0, -10);

        rotateVector = new Vector3(0, 0, 1);

        if (Level % 2 == 0)
        {
            rotateVector = new Vector3(0, 0, -1);
        }

        CircleBorder.gameObject.SetActive(false);

        CircleBorder.localScale = Vector3.one;

        DOTween.Kill(PLAYER);

        PLAYER.localPosition = new Vector3(PLAYER.localPosition.x, floorPosition, PLAYER.localPosition.z);

        guyAnim.MakeItBlink();

        guyAnim.m_collider.enabled = false;

        CreateDotOnCircle();

        CircleBorder.localScale = Vector3.one * 0.001f;
        CircleBorder.gameObject.SetActive(true);

        int count = LIST_SQUARE.Count;

        guyAnim.MakeItBlink();

        guyAnim.m_collider.enabled = false;

        for (int i = 0; i < count; i++)
        {
            DotManager dm = LIST_SQUARE[i];

            dm.ActivateLine(dm.transform.position, dm.transform.parent);

            guyAnim.m_collider.enabled = false;
        }

        CircleBorder.DOScale(Vector3.one, 1)
        .SetDelay(0.3f)
        .SetEase(Ease.InBack)
        .OnComplete(() => {
            canvasManager.ButtonLogic();
            guyAnim.m_collider.enabled = false;

            Invoke("StopBlink", 1);
        });
    }
Пример #3
0
    IEnumerator ShootDot(DotManager dBottom, DotManager dTop)
    {
        canShoot = false;

        lastShootTop    = null;
        lastShootBottom = null;

        StopCoroutine("PositioningDots");
        StopCoroutine("MoveStartPositionDot");

        if (dBottom != null)
        {
            dBottom.GetComponent <Collider2D>().enabled   = true;
            dBottom.GetComponent <Collider2D>().isTrigger = true;
        }
        if (dTop != null)
        {
            dTop.GetComponent <Collider2D>().enabled   = true;
            dTop.GetComponent <Collider2D>().isTrigger = true;
        }

        for (int i = 0; i < DotsTop.Count; i++)
        {
            DotsTop [i].transform.localScale = Vector3.one;


            DotsTop [i].transform.position = getDotPositionTop(i);
        }

        for (int i = 0; i < DotsBottom.Count; i++)
        {
            DotsBottom [i].transform.localScale = Vector3.one;

            DotsBottom [i].transform.position = getDotPositionBottom(i);
        }

        yield return(null);


        if (DotsBottom.Count != 0 || DotsTop.Count != 0)
        {
            PlaySoundShoot();

            if (dBottom != null)
            {
                DotsBottom.Remove(dBottom);
                lastShootBottom = dBottom;
            }

            if (dTop != null)
            {
                DotsTop.Remove(dTop);
                lastShootTop = dTop;
            }

            StartCoroutine(PositioningDots());



            Vector3 targetBttom = new Vector3(0, positionTouchBorderBOTTOM, 0);
            Vector3 targetTop   = new Vector3(0, positionTouchBorderTOP, 0);



            if (dBottom != null)
            {
                dBottom.transform.position = getDotPositionBottom(0);
                //new Vector3 (0, -sizeDot*0.7f, 0);
            }

            if (dTop != null)
            {
                dTop.transform.position = getDotPositionTop(0);
                //new Vector3 (0, sizeDot*0.7f, 0);
            }

            while (true)
            {
                float step = speed * Time.deltaTime;
                if (dBottom != null)
                {
                    dBottom.transform.position = Vector3.MoveTowards(dBottom.transform.position, targetBttom, step);
                }

                if (dTop != null)
                {
                    dTop.transform.position = Vector3.MoveTowards(dTop.transform.position, targetTop, step);
                }

                if (dBottom != null)
                {
                    if (dBottom.transform.position == targetBttom || isGameOver)
                    {
                        canShoot = true;


                        break;
                    }
                }
                else
                {
                    if (dTop.transform.position == targetTop || isGameOver)
                    {
                        canShoot = true;


                        break;
                    }
                }


                yield return(new WaitForEndOfFrame());
            }

            if (dBottom != null)
            {
                dBottom.ActivateLine(targetBttom, CircleBorderBOTTOM);
            }

            if (dTop != null)
            {
                dTop.ActivateLine(targetTop, CircleBorderTOP);
            }

            yield return(new WaitForSeconds(0.001f));

            if (DotsBottom.Count == 0 && DotsTop.Count == 0 && !isGameOver)
            {
                success = true;
            }

            if (success && !isGameOver)
            {
                LevelCleared();
            }

            for (int i = 0; i < DotsTop.Count; i++)
            {
                DotsTop [i].transform.localScale = Vector3.one;

                DotsTop [i].transform.position = getDotPositionTop(i);
            }

            for (int i = 0; i < DotsBottom.Count; i++)
            {
                DotsBottom [i].transform.localScale = Vector3.one;

                DotsBottom [i].transform.position = getDotPositionBottom(i);
            }
        }
    }