Beispiel #1
0
        void CreateListDots()
        {
            canShoot   = false;
            DotsBottom = new List <DotManagerAB>();
            DotsTop    = new List <DotManagerAB>();

//			if (sizeDot == 0)
//			{
//				DotManager dm = InstantiateDot();
//
//				sizeDot = dm.DotSprite.bounds.size.x;
//			}
//
            float numberTOP = numberDotsToCreate;

            for (int i = 0; i < numberTOP; i++)
            {
                DotManagerAB dm = InstantiateDot();

                if (sizeDot == -1)
                {
                    sizeDot = dm.DotSprite.bounds.size.x;
                }

                dm.GetComponent <Collider2D>().enabled = false;
                SetPositionDot(i, dm.transform);
                DotsBottom.Add(dm);


                DotManagerAB dm2 = InstantiateDot();
                dm2.GetComponent <Collider2D>().enabled = false;
                dm2.transform.position = new Vector3(dm.transform.position.x, -dm.transform.position.y, dm.transform.position.z);
                DotsTop.Add(dm2);
            }
        }
Beispiel #2
0
        void CreateDotOnCircle()
        {
            Time.timeScale = 1;

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

            Vector3   posTOP    = new Vector3(0, positionTouchBorder, 0);
            Transform parentTOP = DOTS_PARENT;


            float numberTOP = numberDotsOnCircle;


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

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

                dm.DOParentAndActivateLine(dm.transform.position, dm.transform.parent, true);
            }
        }
Beispiel #3
0
        IEnumerator ShootDot()
        {
            DotManagerAB dBottom = DotsBottom[0];
            DotManagerAB dTop    = DotsTop[0];

            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 < DotsBottom.Count; i++)
            {
                DotsBottom [i].transform.localScale = Vector3.one;

                SetPositionDot(i, DotsBottom [i].transform);
            }

            yield return(null);


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

                lastShootBottom = dBottom;
                lastShootTop    = dTop;

                DotsBottom.RemoveAt(0);
                DotsTop.RemoveAt(0);

                StartCoroutine(PositioningDots());

                Vector3 targetBottom = new Vector3(0, positionTouchBorder, 0);
                Vector3 targetTop    = new Vector3(0, -positionTouchBorder, 0);

                while (true)
                {
                    float step = speed * Time.deltaTime;

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

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


                            break;
                        }
                    }


                    yield return(new WaitForEndOfFrame());
                }

                dBottom.SetParentShootedDot(DOTS_PARENT, true, true);
                dTop.SetParentShootedDot(DOTS_PARENT, true, false);


                yield return(new WaitForSeconds(0.001f));

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

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

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

                    SetPositionDot(i, DotsBottom [i].transform);
                }
            }
        }