Пример #1
0
 public void ShowChangeOut()
 {
     if (isInStage)
     {
         show.transform.parent = Game.Instance.changeOutRoot.transform;
     }
     else
     {
         for (int i = 0, len = show.transform.childCount; i < len; i++)
         {
             GameBufferPool.ReleaseGrid(show.transform.GetChild(0).gameObject);
         }
     }
     for (int i = 0, len = tip.transform.childCount; i < len; i++)
     {
         GameBufferPool.ReleaseGrid(tip.transform.GetChild(0).gameObject);
     }
     for (int i = 0, len = showOut.transform.childCount; i < len; i++)
     {
         GameBufferPool.ReleaseGrid(showOut.transform.GetChild(0).gameObject);
     }
     for (int i = 0, len = shader.transform.childCount; i < len; i++)
     {
         GameBufferPool.ReleaseGrid(shader.transform.GetChild(0).gameObject);
     }
 }
Пример #2
0
 private void Update()
 {
     background.Update();
     GameBufferPool.CheckBuffPool();
     if (Game.Instance != null)
     {
         Game.Instance.Update();
     }
 }
Пример #3
0
 private void OnShowGameChangeOut0(lib.Event e)
 {
     for (int i = 0, len = outBackground.transform.childCount; i < len; i++)
     {
         GameBufferPool.ReleaseGridBg(outBackground.transform.GetChild(0).gameObject);
     }
     for (int i = 0; i < pieces.length; i++)
     {
         if (pieces[i].isInStage == false)
         {
             pieces[i].Hide();
         }
     }
 }
Пример #4
0
 private void OnShowGameChangeOutComplete()
 {
     for (int i = 0; i < outTweens.Count; i++)
     {
         if (outTweens[i].IsPlaying() == true)
         {
             return;
         }
     }
     for (int i = 0, len = changeOutRoot.transform.childCount; i < len; i++)
     {
         for (int j = 0, len2 = changeOutRoot.transform.GetChild(i).childCount; j < len2; j++)
         {
             GameBufferPool.ReleaseGrid(changeOutRoot.transform.GetChild(i).GetChild(0).gameObject);
         }
     }
     MainData.Instance.dispatcher.DispatchWith(EventType.SHOW_GAME_CHANGE_OUT_EFFECT_COMPLETE2, this);
 }
Пример #5
0
        private void OnShowGameChangeOut(lib.Event e)
        {
            for (int i = 0; i < backgroundgrids.Count; i++)
            {
                GameBufferPool.ReleaseGridBg(backgroundgrids[i]);
            }
            changeOutRoot                  = new GameObject();
            changeOutRoot.name             = "GameChangeOut";
            changeOutRoot.transform.parent = root.transform.parent;
            for (int i = 0; i < this.pieces.length; i++)
            {
                pieces[i].ShowChangeOut();
            }
            root.SetActive(false);
            outTweens = new List <Tweener>();
            float   maxTime  = 0;
            Tweener maxTween = null;

            foreach (Transform child in changeOutRoot.transform)
            {
                foreach (Transform child2 in child)
                {
                    float time1 = UnityEngine.Random.Range(0.1f, 0.6f);
                    float time2 = UnityEngine.Random.Range(0.0f, 0.3f);
                    child2.GetComponent <SpriteRenderer>().DOColor(new Color(1, 1, 1, 0), time1).SetDelay(time2);
                    Tweener tween = child2.DOMove(new Vector3(UnityEngine.Random.Range(-7.2f, -8.0f), UnityEngine.Random.Range(child2.position.y - 3f, child2.position.y + 3f)), time1).SetDelay(time2).SetEase(Ease.InSine);
                    outTweens.Add(tween);
                    tween.onComplete = OnShowGameChangeOutComplete;
                    if (time1 + time2 > maxTime)
                    {
                        maxTime  = time1 + time2;
                        maxTween = tween;
                    }
                }
            }
        }
Пример #6
0
        public void CreateDisplay()
        {
            //创建拖动显示
            for (int i = 0; i < coords.length; i++)
            {
                GameObject image    = GameBufferPool.CreateGrid(coords[i].type);
                Point2D    position = HaxgonCoord <Coord> .CoordToPosition(Point2D.Create(coords[i].x, coords[i].y), 0.4f);

                image.transform.localPosition = new Vector3(position.x, position.y, 1);
                image.transform.parent        = show.transform;
            }
            show.SetActive(false);

            if (isAnswer)
            {
                //创建提示
                tipGrids = new List <SpriteRenderer>();
                for (int i = 0; i < coords.length; i++)
                {
                    GameObject image    = GameBufferPool.CreateGrid(coords[i].type);
                    Point2D    position = HaxgonCoord <Coord> .CoordToPosition(Point2D.Create(coords[i].x, coords[i].y), 0.4f);

                    image.transform.localPosition = new Vector3(position.x, position.y, 3);
                    image.transform.parent        = tip.transform;
                    tipGrids.Add(image.GetComponent <SpriteRenderer>());
                    image.GetComponent <SpriteRenderer>().color = new Color(image.GetComponent <SpriteRenderer>().color.r, image.GetComponent <SpriteRenderer>().color.g, image.GetComponent <SpriteRenderer>().color.b, shaderAlpha);
                }
                tip.transform.localPosition = new Vector3(Game.Instance.offx, Game.Instance.offy, -3);
                tip.SetActive(false);
            }

            //创建阴影
            for (int i = 0; i < coords.length; i++)
            {
                GameObject image = GameBufferPool.CreateGrid(coords[i].type);
                shaders.Add(image);
                Point2D position = HaxgonCoord <Coord> .CoordToPosition(Point2D.Create(coords[i].x, coords[i].y), 0.4f);

                image.transform.localPosition = new Vector3(position.x, position.y, 3);
                image.transform.parent        = shader.transform;
                image.GetComponent <SpriteRenderer>().color = new Color(image.GetComponent <SpriteRenderer>().color.r, image.GetComponent <SpriteRenderer>().color.g, image.GetComponent <SpriteRenderer>().color.b, shaderAlpha);
            }
            shader.SetActive(false);

            //创建库中的显示
            for (int i = 0; i < coords.length; i++)
            {
                Point2D position = HaxgonCoord <Coord> .CoordToPosition(Point2D.Create(coords[i].x, coords[i].y), 0.2f);

                Point2D position2 = HaxgonCoord <Coord> .CoordToPosition(Point2D.Create(outCoord.x, outCoord.y), 0.2f);

                position.x += position2.x;
                position.y += position2.y;

                GameObject image;
                image = GameBufferPool.CreateGrid(coords[i].type);
                image.transform.localScale    = new Vector3(0.5f, 0.5f);
                image.transform.localPosition = new Vector3(position.x, position.y, 3);
                image.transform.parent        = showOut.transform;


                if (!HasCoordAt(HaxgonCoord <Coord> .GetCoordNextTo(Point2D.Create(coords[i].x, coords[i].y), HaxgonCoordNextDirection.UP)))
                {
                    image = GameBufferPool.CreateGridSide();
                    image.transform.localScale    = new Vector3(0.5f, 0.5f);
                    image.transform.localPosition = new Vector3(position.x + offx * 0.5f, position.y + offy * 0.5f + 0.17f * HaxgonCoord <Coord> .halfSqrt3, 4);
                    image.transform.parent        = background.transform;
                }

                if (!HasCoordAt(HaxgonCoord <Coord> .GetCoordNextTo(Point2D.Create(coords[i].x, coords[i].y), HaxgonCoordNextDirection.RIGHT_UP)))
                {
                    image = GameBufferPool.CreateGridSide();
                    image.transform.localScale    = new Vector3(0.5f, 0.5f);
                    image.transform.localPosition = new Vector3(position.x + offx * 0.5f + 0.17f * 0.75f, position.y + offy * 0.5f + 0.5f * 0.17f * HaxgonCoord <Coord> .halfSqrt3, 4);
                    image.transform.eulerAngles   = new Vector3(0, 0, -60);
                    image.transform.parent        = background.transform;
                }

                if (!HasCoordAt(HaxgonCoord <Coord> .GetCoordNextTo(Point2D.Create(coords[i].x, coords[i].y), HaxgonCoordNextDirection.RIGHT_DOWN)))
                {
                    image = GameBufferPool.CreateGridSide();
                    image.transform.localScale    = new Vector3(0.5f, 0.5f);
                    image.transform.localPosition = new Vector3(position.x + offx * 0.5f + 0.17f * 0.75f, position.y + offy * 0.5f - 0.5f * 0.17f * HaxgonCoord <Coord> .halfSqrt3, 4);
                    image.transform.eulerAngles   = new Vector3(0, 0, 60);
                    image.transform.parent        = background.transform;
                }

                if (!HasCoordAt(HaxgonCoord <Coord> .GetCoordNextTo(Point2D.Create(coords[i].x, coords[i].y), HaxgonCoordNextDirection.DOWN)))
                {
                    image = GameBufferPool.CreateGridSide();
                    image.transform.localScale    = new Vector3(0.5f, 0.5f);
                    image.transform.localPosition = new Vector3(position.x + offx * 0.5f, position.y + offy * 0.5f - 0.17f * HaxgonCoord <Coord> .halfSqrt3, 4);
                    image.transform.parent        = background.transform;
                }

                if (!HasCoordAt(HaxgonCoord <Coord> .GetCoordNextTo(Point2D.Create(coords[i].x, coords[i].y), HaxgonCoordNextDirection.LEFT_DOWN)))
                {
                    image = GameBufferPool.CreateGridSide();
                    image.transform.localScale    = new Vector3(0.5f, 0.5f);
                    image.transform.localPosition = new Vector3(position.x + offx * 0.5f - 0.17f * 0.75f, position.y + offy * 0.5f - 0.5f * 0.17f * HaxgonCoord <Coord> .halfSqrt3, 4);
                    image.transform.eulerAngles   = new Vector3(0, 0, -60);
                    image.transform.parent        = background.transform;
                }

                if (!HasCoordAt(HaxgonCoord <Coord> .GetCoordNextTo(Point2D.Create(coords[i].x, coords[i].y), HaxgonCoordNextDirection.LEFT_UP)))
                {
                    image = GameBufferPool.CreateGridSide();
                    image.transform.localScale    = new Vector3(0.5f, 0.5f);
                    image.transform.localPosition = new Vector3(position.x + offx * 0.5f - 0.17f * 0.75f, position.y + offy * 0.5f + 0.5f * 0.17f * HaxgonCoord <Coord> .halfSqrt3, 4);
                    image.transform.eulerAngles   = new Vector3(0, 0, 60);
                    image.transform.parent        = background.transform;
                }
            }
            showOut.transform.localPosition = new Vector3(game.offx1 + offx * 0.5f, game.offy1 + offy * 0.5f);
        }
Пример #7
0
        private void CreateDisplay()
        {
            //生成背景
            float      minX = 1000;
            float      maxX = -1000;
            float      minY = 1000;
            float      maxY = -1000;
            GameObject p    = new GameObject();

            p.transform.parent = rootStage.transform;
            foreach (var item in coordSys.coords)
            {
                Coord      coord = item.Value;
                GameObject image = GameBufferPool.CreateGridBg();
                backgroundgrids.Add(image);
                Point2D position = HaxgonCoord <Coord> .CoordToPosition(Point2D.Create(coord.x, coord.y), 0.4f);

                image.transform.position = new Vector3(position.x, position.y, 5);
                image.transform.parent   = p.transform;
                if (position.x < minX)
                {
                    minX = position.x;
                }
                if (position.x > maxX)
                {
                    maxX = position.x;
                }
                if (position.y < minY)
                {
                    minY = position.y;
                }
                if (position.y > maxY)
                {
                    maxY = position.y;
                }
            }
            MainData.Instance.levelWidth  = maxX - minX + 1.5f;
            MainData.Instance.levelHeight = maxY - minY + 1.5f;
            offx = -((maxX - minX) * 0.5f + minX);
            offy = -((maxY - minY) * 0.5f + minY) + GameVO.Instance.Height * 0.2f;
            p.transform.position = new Vector3(offx, offy - GameVO.Instance.Height * 0.2f);
            stageRoot            = p;

            rootStage.transform.localPosition = new Vector3(0, GameVO.Instance.Height * 0.2f);

            outBackground = new GameObject();
            outBackground.transform.parent = root.transform;
            //outBackground.SetActive(!MainData.Instance.isLoading);

            //生成背景
            minX = 1000;
            maxX = -1000;
            minY = 1000;
            maxY = -1000;
            GameObject p1 = new GameObject();

            p1.transform.parent = root.transform;
            for (int x = 0; x < this.maxx; x++)
            {
                for (int py = 0; py > this.miny; py--)
                {
                    int     y        = py - 3 + movesy[x];
                    Point2D position = HaxgonCoord <Coord> .CoordToPosition(Point2D.Create(x, y), 0.2f);

                    /*
                     * GameObject image = ResourceManager.CreateImage("image/grid/gridBg");
                     * image.transform.localScale = new Vector3(0.5f, 0.5f);
                     * image.transform.position = new Vector3(position.x, position.y,100);
                     * image.transform.parent = p1.transform;
                     * //*/

                    if (position.x < minX)
                    {
                        minX = position.x;
                    }
                    if (position.x > maxX)
                    {
                        maxX = position.x;
                    }
                    if (position.y < minY)
                    {
                        minY = position.y;
                    }
                    if (position.y > maxY)
                    {
                        maxY = position.y;
                    }
                }
            }
            offx1 = -((maxX - minX) * 0.5f + minX);
            offy1 = -((maxY - minY) * 0.5f + minY) - 2.4f;
            p1.transform.position = new Vector3(offx1, offy1);

            for (int i = 0; i < pieces.length; i++)
            {
                pieces[i].background = outBackground;
                pieces[i].CreateDisplay();
            }

            outBackground.transform.position = new Vector3(offx1, offy1);
        }