示例#1
0
    public void CreateNewNote(TileData data, Vector3 spawnPos, int tileIndex, int column, int height, bool withBonusTile = false, BonusType bonusType = BonusType.Diamond)
    {
        if (data.type == TileType.LongNote)
        {
            NoteMulti multi = PopMulti("multi_buffer");
            multi.Setup(data, spawnPos, tileIndex, column, height);
            if (listNoteActive.Contains(multi))
            {
                listNoteActive.Remove(multi);
            }
            listNoteActive.Add(multi);
        }
        else
        {
            NoteSimple simple = PopSimple("simple_buffer");
            simple.Setup(data, spawnPos, tileIndex, column, height);
            if (listNoteActive.Contains(simple))
            {
                listNoteActive.Remove(simple);
            }
            listNoteActive.Add(simple);
        }

        if (withBonusTile)
        {
            NoteBonus bonus       = CreateBonusTile(bonusType);
            int       bonusColumn = (column - 2 >= 0) ? column - 2 : column + 2;
            bonus.Setup(data, spawnPos, tileIndex, bonusColumn, height);
            listBonusTiles.Add(bonus);
        }
    }
示例#2
0
    public NoteBonus CreateBonusTile(BonusType type)
    {
        NoteBonus bonus = GameObject.Instantiate(prefabNoteBonus);

        bonus.name = "bonus";

        //NoteBonus bonus = obj.GetComponent<NoteBonus>();
        bonus.isLongNote = false;
        bonus.bonusType  = type;

        return(bonus);
    }
示例#3
0
    public void ProcessControlTouch(TouchCover touch)
    {
        if (!gameStarted)
        {
            return;
        }
        if (touch == null)
        {
            return;
        }

        //Touch Press
        if (touch.phase == TouchPhase.Began)
        {
            Vector2 rayOrigin = noteCamera.ScreenToWorldPoint(touch.position);

            //check if mouse hit any object?
            RaycastHit2D hit = Physics2D.Raycast(rayOrigin, Vector2.zero, 100, ProjectConstants.Layers.MainGameMask);
            if (hit && hit.transform != null)
            {
                string hitObjName = hit.transform.name.ToLower();

                //start object?
                if (gameplay.CurrentGameStage != TileMasterGamePlay.GameState.Playing)
                {
                    if (hitObjName.Contains("start"))
                    {
                        //game start
                        NoteStart noteStart = hit.transform.gameObject.GetComponent <NoteStart>();
                        if (noteStart != null)
                        {
                            noteStart.Press(touch);
                        }
                    }
                }

                //tiles?
                if (gameplay.CurrentGameStage == TileMasterGamePlay.GameState.Playing ||
                    gameplay.CurrentGameStage == TileMasterGamePlay.GameState.Continue ||
                    gameplay.CurrentGameStage == TileMasterGamePlay.GameState.AutoPlay)
                {
                    if (gameplay.CurrentGameStage == TileMasterGamePlay.GameState.Continue)
                    {
                        gameplay.StartGame();
                    }

                    if (hitObjName.Contains("simple_"))
                    {
                        NoteSimple simple = hit.transform.gameObject.GetComponent <NoteSimple>();
                        if (simple != null && CanTouchNote(simple))
                        {
                            simple.Press(touch);
                        }
                    }
                    else if (hitObjName.Contains("multi_"))
                    {
                        NoteMulti multi = hit.transform.gameObject.GetComponent <NoteMulti>();
                        if (multi != null && CanTouchNote(multi))
                        {
                            multi.Press(touch);
                            multi.OnShowUIWhenPress(GetRootPositionHit(touch));
                        }
                    }
                    else if (hitObjName.Contains("bonus"))
                    {
                        NoteBonus bonus = hit.transform.gameObject.GetComponent <NoteBonus>();
                        if (bonus != null)
                        {
                            bonus.Press(null);
                        }
                    }
                }
            }
            else
            {
                //if the touch didn't hit any note, check for hit on background
                RaycastHit2D bgCheck = Physics2D.Raycast(rayOrigin, Vector2.zero, 100, ProjectConstants.Layers.BackgroundMask);
                if (bgCheck.transform != null)
                {
                    if (gameplay.CurrentGameStage == TileMasterGamePlay.GameState.Playing ||
                        gameplay.CurrentGameStage == TileMasterGamePlay.GameState.AutoPlay)
                    {
                        if (CheckGameOver(touch))
                        {
                            GameOverByPressWrong(touch);
                        }
                    }
                    else if (gameplay.CurrentGameStage == TileMasterGamePlay.GameState.Continue)
                    {
                        gameplay.StartGame();
                    }
                }
            }
        }

        // Touch Hold
        else if (touch.phase == TouchPhase.Stationary || touch.phase == TouchPhase.Moved)
        {
            OnHoldTouch(touch);
        }
        else
        {
            ResetTouch(touch);
        }
    }