コード例 #1
0
    public static void setPuyoALinkList(Puyo puyoA, Puyo puyoB)
    {
        List <Puyo> puyoAList = puyoA.getLinkPuyoList();

        if (!puyoAList.Contains(puyoB))
        {
            puyoAList.Add(puyoB);
        }
        List <Puyo> puyoBList = puyoB.getLinkPuyoList();

        if (!puyoBList.Contains(puyoA))
        {
            puyoBList.Add(puyoA);
        }
        List <Puyo> puyoCList = puyoAList.Union(puyoBList).ToList <Puyo>();

        for (int i = 0; i < puyoAList.Count; i++)
        {
            puyoAList[i].setLinkPuyoList(puyoCList);
        }
        for (int i = 0; i < puyoBList.Count; i++)
        {
            puyoBList[i].setLinkPuyoList(puyoCList);
        }
    }
コード例 #2
0
    public static void setPuyoImage(Puyo puyo, string imgKey)
    {
        Image puyoImage = puyo.getPuyoObj().GetComponent <Image>();

        switch (puyo.getColor())
        {
        case 0:
            puyoImage.sprite = bluePuyoImgDic[imgKey];
            break;

        case 1:
            puyoImage.sprite = greenPuyoImgDic[imgKey];
            break;

        case 2:
            puyoImage.sprite = purplePuyoImgDic[imgKey];
            break;

        case 3:
            puyoImage.sprite = redPuyoImgDic[imgKey];
            break;

        case 4:
            puyoImage.sprite = yellowPuyoImgDic[imgKey];
            break;
        }
    }
コード例 #3
0
    public Puyo TrashCreate(int x, int y)
    {
        Puyo puyo = player.puyoArr[x, y];

        if (puyo != null)
        {
            Destroy(puyo.getPuyoObj());
            puyo = null;
        }
        puyo.setColor(5);
        puyo.setLinkStatus(ImageController.NORMAL);

        GameObject newPuyoObj = Instantiate(greyPuyoGameObject);

        newPuyoObj.transform.localPosition = new Vector3(x, y, 0);
        newPuyoObj.transform.localScale    = new Vector3(1, 1, 1);
        puyo.setPuyoObj(newPuyoObj);

        List <Puyo> puyoList = new List <Puyo>();

        puyoList.Add(puyo);
        puyo.setLinkPuyoList(puyoList);

        return(puyo);
    }
コード例 #4
0
ファイル: PuyoQueue.cs プロジェクト: analog-hors/PuyoPuyoProj
        public PuyoQueue(int seed)
        {
            rng   = new Random(seed);//Ignores sign bit so it's really a 31 bit seed :P
            puyos = new Puyo[] {
                Puyo.RED,
                Puyo.GREEN,
                Puyo.BLUE,
                Puyo.YELLOW,
                Puyo.PURPLE
            };
            int n = puyos.Length;

            while (n > 1)
            {
                int  k    = rng.Next(n--);
                Puyo temp = puyos[n];
                puyos[n] = puyos[k];
                puyos[k] = temp;
            }
            queue   = new List <Puyo>(4);
            history = new Queue <Puyo>();
            for (int i = 0; i < 4; i++)
            {
                Enqueue(RandPuyo(3));
            }
        }
コード例 #5
0
        public Rectangle PuyoGhostSrcRect(Puyo puyo)
        {
            int x = 16;
            int y = (int)puyo - 1;

            return(new Rectangle(x * TILE_SIZE, y * TILE_SIZE, TILE_SIZE, TILE_SIZE));
        }
コード例 #6
0
ファイル: PuyoQueue.cs プロジェクト: analog-hors/PuyoPuyoProj
 private void Enqueue(Puyo puyo)
 {
     queue.Add(puyo);
     if (history.Count == 2)
     {
         history.Dequeue();
     }
     history.Enqueue(puyo);
 }
コード例 #7
0
ファイル: PuyoGroup.cs プロジェクト: isaveu/puyounity
    public bool ContainPuyo(Puyo puyo)
    {
        if (puyo == null)
        {
            throw new ArgumentNullException("puyo");
        }

        return(Puyos.Any(p => p.Row == puyo.Row && p.Column == puyo.Column));
    }
コード例 #8
0
    //puyoをfield_puyo上に設置する。
    public void SetFieldPuyo(Puyo puyo)
    {
        var pos = puyo.Pos;

        this.field_puyo[pos.x / 2 - 1, pos.y / 2 - 1] = puyo;

        this.field_bool[pos.x, pos.y]         = false;
        this.field_bool[pos.x + 1, pos.y]     = false;
        this.field_bool[pos.x, pos.y + 1]     = false;
        this.field_bool[pos.x + 1, pos.y + 1] = false;
    }
コード例 #9
0
        public Rectangle PuyoSrcRect(Puyo puyo, CardinalDir connections)
        {
            int x = (int)connections;
            int y = (int)puyo - 1;

            if (puyo == Puyo.NUISANCE)
            {
                throw new NotImplementedException();
            }
            return(new Rectangle(x * TILE_SIZE, y * TILE_SIZE, TILE_SIZE, TILE_SIZE));
        }
コード例 #10
0
    IEnumerator DelaySpawn()
    {
        yield return(new WaitUntil(() => !GameBoard.AnyFallingBlocks() && !GameBoard.WhatToDelete()));

        if (GameIsOver())
        {
            GameObject.Find("GameOverCanvas").GetComponent <CanvasGroup>().alpha = 1;
            enabled = false;
        }
        else
        {
            activePuyo = Instantiate((GameObject)Resources.Load("Puyo"), transform.position, Quaternion.identity).GetComponent <Puyo>();
        }
    }
コード例 #11
0
    private IEnumerator AnimateAndDestroy(Puyo puyo)
    {
        var animationComponent = puyos[puyo.Row, puyo.Column].GetComponent <Animation>();

        animationComponent.Play();

        do
        {
            yield return(null);
        } while (animationComponent.isPlaying);

        DestroyPuyo(puyo);

        gameState = GameState.Repositioning;
    }
コード例 #12
0
    private Puyo FindNextPuyoInChain(Puyo puyo, IEnumerable <Puyo> ignoredPuyos)
    {
        var ignoredList = ignoredPuyos.ToList();

        // Top
        if (puyo.Row < GameVariable.Rows - 1 && (ignoredPuyos == null || !ignoredList.Any(p => p.Row == puyo.Row + 1 && p.Column == puyo.Column)))
        {
            var topPuyo = puyos[puyo.Row + 1, puyo.Column];
            if (topPuyo != null && topPuyo.GetComponent <Puyo>().Color == puyo.Color)
            {
                return(topPuyo.GetComponent <Puyo>());
            }
        }

        // Bottom
        if (puyo.Row > 0 && (ignoredPuyos == null || !ignoredList.Any(p => p.Row == puyo.Row - 1 && p.Column == puyo.Column)))
        {
            var bottomPuyo = puyos[puyo.Row - 1, puyo.Column];
            if (bottomPuyo != null && bottomPuyo.GetComponent <Puyo>().Color == puyo.Color)
            {
                return(bottomPuyo.GetComponent <Puyo>());
            }
        }

        // Right
        if (puyo.Column < GameVariable.Columns - 1 && (ignoredPuyos == null || !ignoredList.Any(p => p.Row == puyo.Row && p.Column == puyo.Column + 1)))
        {
            var rightPuyo = puyos[puyo.Row, puyo.Column + 1];
            if (rightPuyo != null && rightPuyo.GetComponent <Puyo>().Color == puyo.Color)
            {
                return(rightPuyo.GetComponent <Puyo>());
            }
        }

        // Left
        if (puyo.Column > 0 && (ignoredPuyos == null || !ignoredList.Any(p => p.Row == puyo.Row && p.Column == puyo.Column - 1)))
        {
            var leftPuyo = puyos[puyo.Row, puyo.Column - 1];
            if (leftPuyo != null && leftPuyo.GetComponent <Puyo>().Color == puyo.Color)
            {
                return(leftPuyo.GetComponent <Puyo>());
            }
        }

        // Nothing is found, return null
        return(null);
    }
コード例 #13
0
    public Puyo PuyoCreate(int x, int y)
    {
        //print("puyo is creating...");
        Puyo puyo = player.puyoGroupObj.AddComponent <Puyo>();

        puyo.setColor(Random.Range(0, 3));
        puyo.setLinkStatus(ImageController.NORMAL);
        GameObject newPuyoObj;

        switch (puyo.getColor())
        {
        case 0:
            newPuyoObj = Instantiate(bluePuyoGameObject);
            break;

        case 1:
            newPuyoObj = Instantiate(greenPuyoGameObject);
            break;

        case 2:
            newPuyoObj = Instantiate(purplePuyoGameObject);
            break;

        case 3:
            newPuyoObj = Instantiate(redPuyoGameObject);
            break;

        case 4:
            newPuyoObj = Instantiate(yellowPuyoGameObject);
            break;

        default:
            newPuyoObj = Instantiate(bluePuyoGameObject);
            break;
        }
        newPuyoObj.transform.SetParent(player.puyoGroupObj.transform);
        newPuyoObj.transform.localPosition = new Vector3(x, y, 0);
        newPuyoObj.transform.localScale    = new Vector3(1, 1, 1);
        puyo.setPuyoObj(newPuyoObj);

        List <Puyo> puyoList = new List <Puyo>();

        puyoList.Add(puyo);
        puyo.setLinkPuyoList(puyoList);

        return(puyo);
    }
コード例 #14
0
ファイル: PuyoQueue.cs プロジェクト: analog-hors/PuyoPuyoProj
 public (Puyo, Puyo) Take()
 {
     (Puyo, Puyo)pair = (queue[0], queue[1]);
     queue.RemoveRange(0, 2);
     for (int i = 0; i < 2; i++)
     {
         Puyo puyo = RandPuyo(4);
         foreach (Puyo prev in history)
         {
             if (prev == puyo)
             {
                 puyo = RandPuyo(4);
                 break;
             }
         }
         Enqueue(puyo);
     }
     return(pair);
 }
コード例 #15
0
    private PuyoGroup FindChain(Puyo puyo)
    {
        var currentChain = new List <Puyo> {
            puyo
        };
        var nextPuyosToCheck = new List <Puyo> {
            puyo
        };

        while (nextPuyosToCheck.Any())
        {
            var pi          = nextPuyosToCheck.First();
            var nextInChain = FindNextPuyoInChain(pi, currentChain);
            while (nextInChain != null)
            {
                currentChain.Add(nextInChain);
                nextPuyosToCheck.Add(nextInChain);
                nextInChain = FindNextPuyoInChain(pi, currentChain);
            }
            nextPuyosToCheck.Remove(pi);
        }

        return(currentChain.Count >= GameVariable.MinimumMatches ? new PuyoGroup(currentChain) : null);
    }
コード例 #16
0
 // Returns if puyo is connected on the bottom
 private bool ConnectedD(int x, int y, Puyo p)
 {
     return (y < 11 && chain.Grid[x, y + 1] == p);
 }
コード例 #17
0
 public PuyoState(Puyo puyo)
 {
     this.puyo = puyo;
 }
コード例 #18
0
 // Returns if puyo is connected on the left
 private bool ConnectedL(int x, int y, Puyo p)
 {
     return (x > 0 && chain.Grid[x - 1, y] == p);
 }
コード例 #19
0
 // Returns if puyo is connected on the top
 private bool ConnectedU(int x, int y, Puyo p)
 {
     return (y > 0 && chain.Grid[x, y - 1] == p);
 }
コード例 #20
0
 // Returns if puyo is connected on the right
 private bool ConnectedR(int x, int y, Puyo p)
 {
     return (x < 5 && chain.Grid[x + 1, y] == p);
 }
コード例 #21
0
 public Puyo_Controller(Vector3 init_pos, GameObject p_board)
 {
     num++;
     this.mpuyo = new Puyo($"mpuyo_{num}", init_pos, p_board);
     this.spuyo = new Puyo($"spuyo_{num}", init_pos + this.s_delta, p_board);
 }
コード例 #22
0
 private void DestroyPuyo(Puyo puyo)
 {
     Destroy(puyos[puyo.Row, puyo.Column]);
     puyos[puyo.Row, puyo.Column] = null;
 }
コード例 #23
0
 void Start()
 {
     puyo = GetComponent <Puyo>();
 }