コード例 #1
0
    GrayBlock GetGrayBlock(iVector3 position)
    {
        GrayBlock grayBlock = null;
        GameBlock gameBlock = InGameManager.Instance.GetGameBlock(position);

        if (gameBlock != null)
        {
            grayBlock = gameBlock.GetComponent <GrayBlock>();
        }
        return(grayBlock);
    }
コード例 #2
0
    bool CheckGrayBlock(iVector3 position)
    {
        if (!BlockTools.ValidPos(position))
        {
            return(false);
        }
        GameBlock gameBlock = InGameManager.Instance.GetGameBlock(position);

        if (gameBlock != null)
        {
            GrayBlock grayBlock = gameBlock.GetComponent <GrayBlock>();
            if (grayBlock != null)
            {
                return(true);
            }
        }
        return(false);
    }
コード例 #3
0
ファイル: InGameManager.cs プロジェクト: Kimsanggu/SpaceBlock
 void MIx()
 {
     Debug.Log("Mix");
     for (int y = 0; y < 5; y++)
     {
         for (int x = 0; x < 5; x++)
         {
             GameBlock gameBlock = GetGameBlock(new iVector3(x, y, 0));
             if (gameBlock != null)
             {
                 ColorBlock ColorBlock = gameBlock.GetComponent <ColorBlock>();
                 if (ColorBlock != null)
                 {
                     ColorBlock.Initialize();
                 }
             }
         }
     }
 }
コード例 #4
0
ファイル: InGameManager.cs プロジェクト: Kimsanggu/SpaceBlock
    bool CheckMix()
    {
        int counting   = 0;
        int totalCount = 0;

        for (int y = 0; y < 5; y++)
        {
            for (int x = 0; x < 5; x++)
            {
                GameBlock  gameBlock  = GetGameBlock(new iVector3(x, y, 0));
                ColorBlock ColorBlock = null;
                if (gameBlock != null)
                {
                    totalCount++;
                    ColorBlock = gameBlock.GetComponent <ColorBlock>();
                }
                if (ColorBlock != null)
                {
                    if (ColorBlock.colorCount > 1)
                    {
                        counting++;
                    }
                }
            }
        }
        if (totalCount.CompareTo(25) != 0)
        {
            return(false);
        }
        if (counting.CompareTo(0) == 0)
        {
            return(true);
        }
        else
        {
            return(false);
        }
    }
コード例 #5
0
    List <ColorBlock> Find4Direction(iVector3 pos)
    {
        List <ColorBlock> list = new List <ColorBlock>();

        for (int i = 0; i < 4; i++)
        {
            iVector3 p = new iVector3();
            switch (i)
            {
            case 0: p = pos.Right; break;

            case 1: p = pos.Left; break;

            case 2: p = pos.Up; break;

            case 3: p = pos.Down; break;
            }
            if (BlockTools.ValidPos(p))
            {
                if (InGameManager.Instance != null)
                {
                    GameBlock gameBlock = InGameManager.Instance.GetGameBlock(p);
                    if (gameBlock != null)
                    {
                        ColorBlock colorBlock = gameBlock.GetComponent <ColorBlock>();
                        if (colorBlock != null)
                        {
                            if (colorBlock.colorType.CompareTo(colorType) == 0)
                            {
                                list.Add(colorBlock);
                            }
                        }
                    }
                }
            }
        }
        return(list);
    }
コード例 #6
0
ファイル: BlockSpawner.cs プロジェクト: Kimsanggu/SpaceBlock
    void Spawn()
    {
        bSpawn = true;
        GameBlock prefab = null;

        switch (spawnList[0])
        {
        case GameBlockType.Bit:
            prefab = PoolManager.Instance.GetPool(PoolType.CharacterBlock).gameObject.GetComponent <GameBlock>();
            break;

        case GameBlockType.Color:
            Transform tr = PoolManager.Instance.GetPool(PoolType.ColorBlock);
            if (tr != null)
            {
                prefab = tr.gameObject.GetComponent <GameBlock>();
            }
            else
            {
                Debug.Log("pool is empty");
                return;
            }
            break;

        case GameBlockType.Item:

            prefab = Instantiate(Resources.Load <GameObject>("Prefabs/ItemBlock")).GetComponent <GameBlock>();
            prefab.GetComponent <ItemBlock>().itemType = ItemType.Bomb;
            prefab.GetComponent <ItemBlock>().Initialize();
            break;

        case GameBlockType.Gray:
            prefab = Instantiate(Resources.Load <GameObject>("Prefabs/GrayBlock")).GetComponent <GameBlock>();
            break;
        }

        prefab.transform.SetParent(transform);
        prefab.transform.localPosition = Vector3.zero;
        prefab.transform.localScale    = Vector3.one;
        switch (spawnList[0])
        {
        case GameBlockType.Bit:
            CharacterBlock chBlock = prefab.GetComponent <CharacterBlock>();
            if (chBlock != null)
            {
                chBlock.target = MissionManager.Instance.bit;
            }
            break;

        case GameBlockType.Color:
            ColorBlock colorBlock = prefab.GetComponent <ColorBlock>();

            if (colorBlock != null)
            {
                colorBlock.GetComponent <RectTransform>().anchoredPosition3D = Vector3.zero;
                colorBlock.GetComponent <RectTransform>().localScale         = Vector3.one;
                colorBlock.Initialize();
                colorBlock.bMove        = true;
                colorBlock.bBounce      = false;
                colorBlock.bByItemBlock = false;
                if (Mathf.Abs(time - checkTime) > intervalTime)    //나오는거 아래꺼 하나만 바운스할때
                {
                    checkTime = time;
                }
            }
            break;

        case GameBlockType.Item:
            break;

        case GameBlockType.Gray:
            break;
        }
        prefab.gameObject.SetActive(true);
        spawnList.RemoveAt(0);
        //Debug.Log("Respawn : " + colorBlock.pos);
    }
コード例 #7
0
ファイル: InGameManager.cs プロジェクト: Kimsanggu/SpaceBlock
    IEnumerator ClearEffect(bool bSuccess)
    {
        if (bSuccess)
        {
            List <int> indexList = new List <int>();
            for (int i = 0; i < 25; i++)
            {
                indexList.Add(i);
            }
            BlockTools.Shuffle(indexList);
            BlockSpawnManager.Instance.MoveStop(10f);
            InGameManager.instance.MoveStop(10f);

            if (25 - GetItemBlockCount() < MissionManager.Instance.blockCount)
            {//남은 블록개수가 아이템으로 바꿔줘야 하는 블록보다 많은 경우
                MissionManager.Instance.blockCount = 25 - GetItemBlockCount();
            }
            List <int> fxList = new List <int>();
            for (int i = 0; i < 25; i++)
            {
                if (MissionManager.Instance.blockCount.CompareTo(0) == 0)
                {
                    break;
                }
                if (fxList.Contains(indexList[i]))
                {
                    continue;
                }

                GameBlock gameBlock = positionList[indexList[i]].GetComponentInChildren <GameBlock>();
                if (gameBlock.type == GameBlockType.Color || gameBlock.type == GameBlockType.Gray)
                {
                    CreateStar(indexList[i], gameBlock);
                    fxList.Add(indexList[i]);
                    yield return(new WaitForSeconds(0.1f));
                }
            }
            yield return(new WaitForSeconds(2f));

            //BlockSpawnManager.Instance.MoveStart();
            //MoveStart();
            for (int i = 0; i < 25; i++)
            {
                GameBlock gameBlock = positionList[indexList[i]].GetComponentInChildren <GameBlock>();
                if (gameBlock != null)
                {
                    if (gameBlock.type == GameBlockType.Item)
                    {
                        gameBlock.Explosion(true);
                        break;
                    }
                }
            }

            while (GetItemBlockCount() > 0)
            {
                yield return(new WaitForEndOfFrame());

                if (CheckMoveBlock())
                {
                    continue;
                }
                //if (bDelay) continue;
                for (int i = 0; i < 25; i++)
                {
                    GameBlock gameBlock = positionList[indexList[i]].GetComponentInChildren <GameBlock>();
                    ItemBlock itemBlock = null;
                    if (gameBlock != null)
                    {
                        if (gameBlock.type == GameBlockType.Item)
                        {
                            if (gameBlock.bDestroy)
                            {
                                continue;
                            }
                            yield return(null);

                            //Debug.Log("ClearEffect : " + gameBlock.pos.ToString2());
                            if (gameBlock == null)
                            {
                                continue;
                            }
                            itemBlock = gameBlock.GetComponent <ItemBlock>();
                            gameBlock.Explosion(true);
                            switch (itemBlock.itemType)
                            {
                            case ItemType.Bomb:
                                InGameManager.instance.MoveStop(0.84f);
                                BlockSpawnManager.Instance.MoveStop(0.84f);
                                //yield return new WaitForSeconds(2f);
                                break;

                            case ItemType.Horizental:
                            case ItemType.Vertical:
                                InGameManager.instance.MoveStop(0.42f);
                                BlockSpawnManager.Instance.MoveStop(0.42f);
                                //yield return new WaitForSeconds(2f);
                                break;
                            }
                            break;
                        }
                    }
                }
                yield return(new WaitForSeconds(0.2f));
            }
            yield return(new WaitForSeconds(1f));

            rocket.Fire(2);
        }
        else//gameover
        {
            SoundManager.Instance.StopBGM();
            SoundManager.Instance.PlayEffect("eff_alert");
            FuelManager.Instance.AllLock(false);
            SoundManager.Instance.PlayEffect("eff_electrical_sparks");
            yield return(new WaitForSeconds(2f));

            FX_Smoke_Black.SetActive(true);
            MissionManager.Instance.MissionPanelOff();
            yield return(new WaitForSeconds(1f));

            FX_Electric.gameObject.SetActive(true);
            FX_Electric.Play();
            SoundManager.Instance.PlayEffect("eff_plasma");
            FX_Electric.gameObject.GetComponent <FXLoop>().loopTime = 1.3f;
            FX_Electric.gameObject.GetComponent <FXLoop>().bLoop    = true;

            rocket.randomBounce.Bounce();
            FX_Electric_Bridge.SetActive(true);
            yield return(new WaitForSeconds(1f));
        }

        MissionManager.Instance.missionParent.gameObject.SetActive(false);
        RectTransform rTr = rocket.gameObject.GetComponent <RectTransform>();

        SoundManager.Instance.PlayEffect("eff_rocket_start");
        while (rTr.anchoredPosition3D.y < 1000f)
        {
            rTr.anchoredPosition3D = Vector3.Lerp(rTr.anchoredPosition3D, new Vector3(0f, 1100f, 0f), Time.deltaTime * rocket.speed);
            yield return(null);
        }
        SoundManager.Instance.StopEffect(SoundName.eff_alert);
        boardParent.SetActive(false);
        rocket.gameObject.SetActive(false);
        fuel.SetActive(false);
        FX_Electric_Bridge.SetActive(false);
        FX_Smoke_Black.SetActive(false);
        FX_Electric.gameObject.SetActive(false);
        btn_Exit.SetActive(false);
        ResultManager.Instance.Initialize(bSuccess);
    }
コード例 #8
0
ファイル: InGameManager.cs プロジェクト: Kimsanggu/SpaceBlock
    IEnumerator FlyStar(int index, GameBlock gameBlock)
    {
        GameObject dummyStar = new GameObject("DummyStar");
        //GameObject star = Instantiate(Resources.Load<GameObject>("Prefabs/FX_LightBall_A"));
        GameObject star = PoolManager.Instance.GetPool(PoolType.FX_LightBall_A).gameObject;

        star.SetActive(true);
        RectTransform starRTr = dummyStar.AddComponent <RectTransform>();

        star.transform.SetParent(ParticleManager.Instance.particleCanvasF.transform);
        dummyStar.transform.SetParent(rocket.transform);
        starRTr.anchoredPosition3D = new Vector3(-450f, 300f, 0f);
        starRTr.localScale         = Vector3.one;
        FollowUI ui = star.AddComponent <FollowUI>();

        ui.bFollow   = true;
        ui.target    = positionList[index].gameObject.GetComponent <RectTransform>();
        ui.subTarget = starRTr;
        float    speed = 4f;
        iVector3 p     = new iVector3(gameBlock.pos.x, gameBlock.pos.y, gameBlock.pos.z);

        star.GetComponent <RectTransform>().anchoredPosition3D = Vector3.zero;
        star.transform.localScale = Vector3.one;
        FX_Electric.gameObject.SetActive(true);
        FX_Electric.Play();
        SoundManager.Instance.PlayEffect("eff_plasma");
        SoundManager.Instance.PlayEffect("eff_finale");
        dummyStar.transform.SetParent(gameBlock.transform);

        while ((starRTr.anchoredPosition3D).sqrMagnitude > 100f)
        {
            starRTr.anchoredPosition3D = Vector3.Lerp(starRTr.anchoredPosition3D, Vector3.zero, Time.deltaTime * speed);
            yield return(null);

            if (starRTr == null)
            {
                break;
            }
        }


        star.SetActive(false);
        dummyStar.SetActive(false);

        //ParticleManager.Instance.SetParticle(ParticleType.ParticleF, Particle.FX_SpreadStar, positionList[BlockTools.iVector3ToIndex(p)].GetComponent<RectTransform>());
        GameObject fx_SpreadStar = PoolManager.Instance.GetPool(PoolType.FX_SpreadStar).gameObject;

        ParticleManager.Instance.SetParticle(ParticleType.ParticleF, fx_SpreadStar, positionList[BlockTools.iVector3ToIndex(p)].GetComponent <RectTransform>());

        if (gameBlock != null)
        {
            ColorBlock colorBlock = gameBlock.GetComponent <ColorBlock>();
            if (colorBlock != null)
            {
                colorBlock.DestroyObject();
            }
            GrayBlock grayBlock = gameBlock.GetComponent <GrayBlock>();
            if (grayBlock != null)
            {
                grayBlock.DestroyObject();
            }
        }

        //이떄 생성되는 느낌의 파티클 한개더
        //ItemBlock itemBlock = Instantiate(Resources.Load<GameObject>("Prefabs/ItemBlock")).GetComponent<ItemBlock>();
        ItemBlock itemBlock = PoolManager.Instance.GetPool(PoolType.ItemBlock).GetComponent <ItemBlock>();

        itemBlock.gameObject.SetActive(true);
        itemBlock.pos      = p;
        itemBlock.itemType = (ItemType)UnityEngine.Random.Range(0, 2);
        itemBlock.transform.SetParent(positionList[index].transform);
        itemBlock.transform.localPosition = Vector3.zero;
        itemBlock.transform.localScale    = Vector3.one;
        itemBlock.bIsParentPos            = true;
        itemBlock.Initialize();
    }
コード例 #9
0
ファイル: InGameManager.cs プロジェクト: Kimsanggu/SpaceBlock
    IEnumerator Auto()//test
    {
        while (true)
        {
            yield return(new WaitForSeconds(0.5f));

            int        count = positionList.Count;
            List <int> index = new List <int>();
            for (int i = 0; i < 25; i++)
            {
                index.Add(i);
            }
            BlockTools.Shuffle(index);
            int maxCount        = 0;
            int maxIndex        = -1;
            int missionIndex    = -1;
            int missionMaxCount = 0;
            int itemIndex       = -1;
            for (int i = 0; i < count; i++)
            {
                GameBlock gameBlock = positionList[index[i]].GetComponentInChildren <GameBlock>();
                if (gameBlock != null)
                {
                    if (gameBlock.type == GameBlockType.Color)
                    {
                        ColorBlock ColorBlock = gameBlock.GetComponent <ColorBlock>();
                        if (ColorBlock != null)
                        {
                            if (ColorBlock.colorCount > 1)
                            {
                                int missionCount = MissionManager.Instance.missionList.Count;
                                for (int j = 0; j < missionCount; j++)
                                {
                                    if (MissionManager.Instance.missionList[j].blockCount > 0)
                                    {
                                        if (ColorBlock.colorType.ToString() == MissionManager.Instance.missionList[j].blockType)
                                        {
                                            //미션에 해당하는 색깔블럭
                                            if (missionMaxCount < ColorBlock.colorCount)
                                            {
                                                missionMaxCount = ColorBlock.colorCount;
                                                missionIndex    = index[i];
                                            }
                                        }
                                    }
                                }
                                if (maxCount < ColorBlock.colorCount)
                                {
                                    maxCount = ColorBlock.colorCount;
                                    maxIndex = index[i];
                                }
                                //ColorBlock.OnClickButton();
                            }
                        }
                    }
                    else if (gameBlock.type == GameBlockType.Item)
                    {
                        ItemBlock itemBlock = gameBlock.GetComponent <ItemBlock>();
                        if (itemBlock != null)
                        {
                            //itemBlock.OnClickButton();
                            itemIndex = index[i];
                        }
                    }
                }
            }
            if (missionIndex != -1)
            {
                InGameManager.instance.positionList[missionIndex].GetComponentInChildren <GameBlock>().OnClickButton();
            }
            else if (itemIndex != -1)
            {
                InGameManager.instance.positionList[itemIndex].GetComponentInChildren <GameBlock>().OnClickButton();
            }
            else if (maxIndex != -1)
            {
                InGameManager.instance.positionList[maxIndex].GetComponentInChildren <GameBlock>().OnClickButton();
            }
            if (bGameClear)
            {
                //OnClickButtonNext();
                yield break;
            }
            if (bGameOver)
            {
                OnClickButtonRetry();
                yield break;
            }
        }
    }
コード例 #10
0
    public void DeselectBlock(GameBlock block)
    {
        block.currSelected = false;

        iTween.MoveTo (block.gameObject, iTween.Hash ("z", 0f, "y", 0f, "time", 0.5f, "easetype", iTween.EaseType.easeOutCubic));
        iTween.ScaleTo (block.gameObject, iTween.Hash ("x", 1f, "y", 1f, "z", 1f, "time", 0.5f, "easetype", iTween.EaseType.linear));
        block.GetComponent<CamTiltMouse> ().TurnOff ();
    }
コード例 #11
0
    public void SelectBlock(GameBlock block)
    {
        block.currSelected = true;

        iTween.MoveTo (block.gameObject, iTween.Hash ("z", -1f, "y", 1.2f, "time", 0.5f, "easetype", iTween.EaseType.easeOutCubic));
        iTween.ScaleTo (block.gameObject, iTween.Hash ("x", 1.5f, "y", 1.5f, "z", 1.5f, "time", 0.5f, "easetype", iTween.EaseType.linear));
        block.GetComponent<CamTiltMouse> ().TurnOn ();

        cameraMoveTarget.x = blockslist [currentSelection].transform.position.x;

        manager.Process (block.info);
    }