示例#1
0
    //--------------------------------------------------------------
    /// Called for every game state change automatically.
    //--------------------------------------------------------------
    public void newStateChange(GameStateManager.GameState _newState)
    {
        // Play the appropriate music based on the new state
        switch (_newState)
        {
        case GameStateManager.GameState.MAIN_MENU:
            stopAllClips("MAIN_MENU_MUSIC");
            playClip("MAIN_MENU_MUSIC", true);
            break;

        case GameStateManager.GameState.PLAYING:
            stopAllClips();
            playClip("GAMEPLAY_MUSIC", true);
            break;

        case GameStateManager.GameState.GAME_OVER:
            stopAllClips("GAMEPLAY_MUSIC");
            fadeClipOut("GAMEPLAY_MUSIC");
            if (game.getWinnerName().Contains(PhotonNetwork.player.name))
            {
                playClip("WIN_SOUND");
            }
            else
            {
                playClip("LOSE_SOUND");
            }
            break;
        }
    }
示例#2
0
        public void SwitchState(SpaceInvaders pGame, GameStateManager.GameState nextState)
        {
            // Detach current state input observers
            pGame.DetachStateInputObservers();

            // Queue any Time Events for later
            TimeEvent pTimeEvent = TimerManager.Pop();

            while (pTimeEvent != null)
            {
                this.GetQueuedTimeEventManager().Enqueue(pTimeEvent.GetName(), pTimeEvent.GetCommand(), pTimeEvent.GetDeltaTime());
                pTimeEvent = TimerManager.Pop();
            }

            // Change game state
            pGame.SetGameState(nextState);

            // Load up TimerManager with next state's Time Events
            QueuedTimeEvent qte = pGame.GetStateQueuedTimeEventManager().Dequeue();

            while (qte != null)
            {
                TimerManager.Add(qte.GetTimeEventName(), qte.GetCommand(), qte.GetTimeEventDelta());

                // Get next queued event
                qte = pGame.GetStateQueuedTimeEventManager().Dequeue();
            }

            // Attach next state input observers
            pGame.AttachStateInputObservers();
        }
示例#3
0
 // Methods
 public static void CheckAndLockCursor()
 {
     if (Input.GetKeyUp(KeyCode.LeftControl))
     {
         isCtrlKeyDown = false;
     }
     if (Input.GetKeyDown(KeyCode.LeftControl) && !isCtrlKeyDown)
     {
         if (CtrlFlag)
         {
             FightUIInterface.ShowPromptText("原始操作模式", 1, 1f);
             CtrlFlag = false;
         }
         else
         {
             FightUIInterface.ShowPromptText("新增操作模式", 1, 1f);
             CtrlFlag = true;
         }
         isCtrlKeyDown = true;
     }
     if (CtrlFlag)
     {
         GameStateManager.GameState state = Main.stateMgr.getCurrState();
         if (!MainMenu.InjectedField && ((state == GameStateManager.GameState.Fighting) || (state == GameStateManager.GameState.Normal)))
         {
             Screen.lockCursor = true;
             Screen.showCursor = false;
             return;
         }
     }
     Screen.lockCursor = false;
     Screen.showCursor = true;
 }
示例#4
0
    private void OnGameStateChangeEventHandler(GameStateManager.GameState previous, GameStateManager.GameState current)
    {
        if (previous == GameStateManager.GameState.RUNNING && current == GameStateManager.GameState.RUNNING)
        {
            if (levels.Contains(SceneController.Instance.previousLevel))
            {
                SceneController.Instance.SetTransitionActive(false);

                foreach (GameObject obj in deactivate)
                {
                    obj.SetActive(true);
                }
            }
            else
            {
                SceneController.Instance.SetTransitionActive(true);

                foreach (GameObject obj in deactivate)
                {
                    obj.SetActive(false);
                }
            }

            loaded   = !loaded;
            unloaded = false;
        }
    }
示例#5
0
        private void OnGameStateChanged(GameStateManager.GameState old, GameStateManager.GameState current)
        {
            bool  gameStopped = current == GameStateManager.GameState.LOSE || current == GameStateManager.GameState.WIN || current == GameStateManager.GameState.PAUSE;
            float timeScale   = gameStopped ? 0 : 1;

            SetTimeScale(timeScale);
        }
 private void OnGameStateChangeEventHandler(GameStateManager.GameState previous, GameStateManager.GameState current)
 {
     if (transitionActive && previous == GameStateManager.GameState.RUNNING && current == GameStateManager.GameState.RUNNING)
     {
         UnloadLevel();
     }
 }
示例#7
0
        private void UpdateState(GameStateManager.GameState state)
        {
            _characterController.enabled = state == GameStateManager.GameState.Playing;

            if (!_characterController.enabled)
            {
                _rigidbody.velocity = Vector3.zero;
            }
        }
示例#8
0
 //--------------------------------------------------------------
 /// Automatically called when a player disconnects from the room.
 //--------------------------------------------------------------
 void onPhotonPlayerDisconnected(PhotonPlayer newPlayer)
 {
     GameStateManager.GameState currentState = game.getGameStateManager().getGameState();
     if (currentState == GameStateManager.GameState.PLAYING ||
         currentState == GameStateManager.GameState.WAITING)
     {
         PhotonNetwork.room.maxPlayers--;
     }
 }
示例#9
0
文件: Enemy.cs 项目: z3nk0/VLTest
 private void OnGameStateChanged(GameStateManager.GameState last, GameStateManager.GameState newState)
 {
     if (newState == GameStateManager.GameState.WIN || newState == GameStateManager.GameState.LOSE)
     {
         Dead();
     }
     else if (newState == GameStateManager.GameState.MENU)
     {
         Deactivate();
     }
 }
示例#10
0
    //--------------------------------------------------------------
    /// Called when the game state is changed
    //--------------------------------------------------------------
    public void newStateChange(GameStateManager.GameState _newState)
    {
        string stateString = _newState.ToString();

        for (int i = 0; i < buttons.Length / 2; i++)
        {
            if (buttons[i, 1] == stateString)
            {
                activeMenuItemPushed = false;
                activeMenuItemIndex  = i;
                activeMenuItemName   = buttons[i, 0];
                return;
            }
        }
    }
示例#11
0
    // Start is called before the first frame update
    void Start()
    {
        ghostState = GameStateManager.GameState.Walking;
        prevState  = ghostState;
        behaviour  = defaultBehaviour;
        tweener    = GetComponent <Tweener>();
        animator   = GetComponent <Animator>();
        rend       = GetComponent <SpriteRenderer>();

        column = spawnColumn;
        row    = spawnRow;
        gameObject.transform.position = new Vector2(xSpawnPosition * dis, ySpawnPosition * dis);
        setAdjacent(0, 0);
        currentInput = Direction.Left;
        lastInput    = Direction.Left;
        animator.SetTrigger("Left");
    }
示例#12
0
    public void StartPlacing(Building prefab)
    {
        _prevGameState = GameStateManager.Instance.State;
        GameStateManager.Instance.State = GameStateManager.GameState.Placing;

        // show the grid
        GridGraphics.SetVisible(true);

        // assign the prefab
        ObjectPrefab = prefab;

        // create and attach the preview
        _objectPreviewGraphics = ObjectPrefab.CreatePreview();
        Vector2 gfxOffset = _objectPreviewGraphics.localPosition;

        _objectPreviewGraphics.parent        = ObjectPreview;
        _objectPreviewGraphics.localPosition = gfxOffset;
    }
示例#13
0
        void Update()
        {
            GameStateManager.GameState GAME_STATE = GameStateManager.STATE;

            //Always be able to reset
            if (Input.GetKey(KeyCode.Alpha1) && Input.GetKey(KeyCode.Alpha9))
            {
                GAME_STATE = GameStateManager.GameState.Reset;
                m_ProgressConfig.m_CurrentProgress = 0;
                m_ProgressConfig.FailureCount      = 0;
                m_ProgressConfig.TRexScore         = 0;
                m_ProgressConfig.StegosaursScore   = 0;
                m_ProgressConfig.PterosaursScore   = 0;
                GameSaveManager.ClearStoredScore();
                GameStateManager.SetCurrentState(GameStateManager.GameState.MailReading);

                SceneManager.LoadScene(firstSceneName);
            }
        }
示例#14
0
 private void OnGameStateChanged(GameStateManager.GameState last, GameStateManager.GameState current)
 {
     if (current == GameStateManager.GameState.GAME)
     {
         if (last != GameStateManager.GameState.PAUSE)
         {
             InitializeLevel();
         }
         StartCoroutine(SpawnLoop());
     }
     else
     {
         StopAllCoroutines();
         if (current == GameStateManager.GameState.MENU)
         {
             SceneManager.LoadScene(scenes.menuScene);
         }
     }
 }
示例#15
0
    //Handle states
    private void Update()
    {
        //Get the game state
        GameStateManager.GameState GAME_STATE = GameStateManager.STATE;

        //Always be able to reset
        if (Input.GetKeyDown(KeyCode.R))
        {
            Restart();
        }

        //Handle each game state
        switch (GAME_STATE)
        {
        case GameStateManager.GameState.Init:

            //Increment our week number
            WEEK++;

            //Load any emails taht start on this week
            LoadEmails();

            //Init the actions list, set our day begin screen off, then change states.
            InitActionList();

            //Load in a status and turn it on
            LoadStatus();
            STATUS_BAR.SetActive(true);

            DAY_BEGIN_SCREEN.SetActive(false);
            ALL_EMAIL_SCREEN.GetComponent <AllEmailScreenManager>().InitList(EMAIL_LIST);
            GameStateManager.SetCurrentState(GameStateManager.GameState.PlayerInput);
            break;

        case GameStateManager.GameState.PlayerInput:
            //Handle the state of player input
            switch (STATE)
            {
            case EmailSiteState.AllEmails:
                //If this isn't on, turn it on.
                if (!ALL_EMAIL_SCREEN.activeSelf)
                {
                    DAY_BEGIN_SCREEN.SetActive(false);
                    PROCESS_SCREEN.SetActive(false);
                    ONE_EMAIL_SCREEN.SetActive(false);
                    BM.ApplyColors(BackgroundManager.BackgroundStates.Inbox);
                    ALL_EMAIL_SCREEN.SetActive(true);
                }

                //Update the list
                ALL_EMAIL_SCREEN.GetComponent <AllEmailScreenManager>().UpdateList(ACTION_LIST);
                break;

            case EmailSiteState.OneEmail:
                ONE_EMAIL_SCREEN.GetComponent <OneEmailScreenManager>().SetEmail(SELECTED_EMAIL);
                //If this isn't on, turn it on, and turn the other one off.
                if (!ONE_EMAIL_SCREEN.activeSelf)
                {
                    DAY_BEGIN_SCREEN.SetActive(false);
                    PROCESS_SCREEN.SetActive(false);
                    ALL_EMAIL_SCREEN.SetActive(false);
                    BM.ApplyColors(BackgroundManager.BackgroundStates.Email);
                    ONE_EMAIL_SCREEN.SetActive(true);
                }
                break;

            default:
                Debug.Log("Error, shouldn't happen. Email site state is invalid.");
                break;
            }
            break;

        case GameStateManager.GameState.Processing:
            //Disable relevent screens and enable the right one.
            if (!PROCESS_SCREEN.activeSelf)
            {
                DAY_BEGIN_SCREEN.SetActive(false);
                ALL_EMAIL_SCREEN.SetActive(false);
                ONE_EMAIL_SCREEN.SetActive(false);
                STATUS_BAR.SetActive(false);
                BM.ApplyColors(BackgroundManager.BackgroundStates.Sleep);
                PROCESS_SCREEN.SetActive(true);
            }
            break;

        case GameStateManager.GameState.Waiting:
            if (!DAY_BEGIN_SCREEN.activeSelf)
            {
                //If we just finished week 4, we should end the game, else do the default
                if (WEEK != 4)
                {
                    ALL_EMAIL_SCREEN.SetActive(false);
                    ONE_EMAIL_SCREEN.SetActive(false);
                    PROCESS_SCREEN.SetActive(false);
                    BM.ApplyColors(BackgroundManager.BackgroundStates.Message);
                    DAY_BEGIN_SCREEN.SetActive(true);
                    DAY_BEGIN_SCREEN.GetComponent <DayBeginScreenManager>().InitScreen();
                }
                else
                {
                    //Do the final message thing
                    ALL_EMAIL_SCREEN.SetActive(false);
                    ONE_EMAIL_SCREEN.SetActive(false);
                    PROCESS_SCREEN.SetActive(false);
                    DAY_BEGIN_SCREEN.SetActive(false);
                    BM.ApplyColors(BackgroundManager.BackgroundStates.End);
                    END_SCREEN.SetActive(true);

                    END_SCREEN.GetComponent <EndScreenManager>().EndGame();
                }
            }
            break;

        case GameStateManager.GameState.Restarting:
            Debug.Log("restarting");

            //Find any missing objects
            if (DAY_BEGIN_SCREEN == null)
            {
                Debug.Log("Looking for replacements");
                DESKTOP          = GameObject.Find("Desktop");
                DAY_BEGIN_SCREEN = FindObject(DESKTOP, "Day Begin Screen");
                ALL_EMAIL_SCREEN = FindObject(DESKTOP, "All Emails Screen");
                ONE_EMAIL_SCREEN = FindObject(DESKTOP, "One Email Screen");
                PROCESS_SCREEN   = FindObject(DESKTOP, "Process Screen");
                STATUS_BAR       = FindObject(DESKTOP, "StatusBar");
                END_SCREEN       = FindObject(DESKTOP, "End Screen");
                BM = GameObject.Find("Background").GetComponent <BackgroundManager>();

                if (DAY_BEGIN_SCREEN != null)
                {
                    Debug.Log("Replacement found");
                    //Set to init.
                    InitActionList();
                    InitEmailList();
                    SetGameStateManager(1);
                }
            }

            break;

        default:
            Debug.Log("Invalid game state!");
            break;
        }
    }
示例#16
0
    protected virtual void Start()
    {
        this.previousGameState = MavaruOnlineMain.GameStateManager.State;
        MavaruOnlineMain.GameStateManager.State = GameStateManager.GameState.IN_MESSAGE_BOARD;

        this.scrollPositions = new Dictionary<int, Vector2>();

        this.boardStyle = new GUIStyle();
        boardStyle.normal.background = board;

        this.messageStyle = new GUIStyle();
        messageStyle.padding = new RectOffset(25,0,40,0);
        messageStyle.normal.background = message;

        this.labelsStyle = new GUIStyle();
        labelsStyle.fixedWidth = 40;
        labelsStyle.normal.textColor = Color.black;

        this.textStyle = new GUIStyle();
        textStyle.fixedWidth = messageWidth - 40;
        textStyle.normal.textColor = Color.black;

        this.messageTextStyle = new GUIStyle();
        //messageTextStyle.fixedWidth = messageWidth;
        messageTextStyle.normal.textColor = Color.black;
        messageTextStyle.margin.top = 15;
        messageTextStyle.margin.bottom = 30;
        messageTextStyle.fontStyle = FontStyle.Bold;

        this.deleteButtonStyle = new GUIStyle();
        deleteButtonStyle.fixedWidth = 64;
        deleteButtonStyle.fixedHeight = 32;
        deleteButtonStyle.alignment = TextAnchor.MiddleRight;
        deleteButtonStyle.normal.background = deleteButton;
        deleteButtonStyle.hover.background = deleteButtonSelected;

        this.replyButtonStyle = new GUIStyle(deleteButtonStyle);
        replyButtonStyle.normal.background = replyButton;
        replyButtonStyle.hover.background = replyButtonSelected;

        this.cancelButtonStyle = new GUIStyle(deleteButtonStyle);
        cancelButtonStyle.normal.background = cancelButton;
        cancelButtonStyle.hover.background = cancelButtonSelected;
        cancelButtonStyle.fixedWidth = 99;
        cancelButtonStyle.fixedHeight = 51;
        cancelButtonStyle.margin = cancelMargin;

        this.writeButtonStyle = new GUIStyle(cancelButtonStyle);
        writeButtonStyle.normal.background = writeButton;
        writeButtonStyle.hover.background = writeButtonSelected;
        writeButtonStyle.margin = writeMargin;

        this.privateButtonStyle = new GUIStyle(cancelButtonStyle);
        privateButtonStyle.normal.background = privateButton;
        privateButtonStyle.hover.background = privateButtonSelected;
        privateButtonStyle.margin = privateMargin;

        this.publicButtonStyle = new GUIStyle(cancelButtonStyle);
        publicButtonStyle.normal.background = publicButton;
        publicButtonStyle.hover.background = publicButtonSelected;
        publicButtonStyle.margin = publicMargin;
    }
示例#17
0
 public GamePlayer1State(GameStateManager.GameState stateName)
     : base(stateName)
 {
 }
示例#18
0
 public GameStateChangedArgs(GameStateManager.GameState state)
 {
     _state = state;
 }
示例#19
0
文件: UIGame.cs 项目: z3nk0/VLTest
 private void OnGameStateChanged(GameStateManager.GameState old, GameStateManager.GameState newState)
 {
     gamePanel.SetActive(newState == GameStateManager.GameState.GAME);
     pausePanel.SetActive(newState == GameStateManager.GameState.PAUSE);
     finishPanel.SetActive(newState == GameStateManager.GameState.LOSE || newState == GameStateManager.GameState.WIN);
 }
示例#20
0
 public GameAttractState(GameStateManager.GameState stateName)
     : base(stateName)
 {
 }
示例#21
0
 public SpaceInvadersGameState(GameStateManager.GameState inStateName)
 {
     this.stateName = inStateName;
 }
示例#22
0
文件: HideMouse.cs 项目: z3nk0/VLTest
        private void OnGameStateChanged(GameStateManager.GameState old, GameStateManager.GameState newState)
        {
            bool hideMouse = newState == GameStateManager.GameState.GAME;

            SetCursorVisibility(hideMouse);
        }
示例#23
0
文件: UIFinish.cs 项目: z3nk0/VLTest
 private void OnEnable()
 {
     GameStateManager.GameState current = GameStateManager.currentState;
     title.text    = current == GameStateManager.GameState.WIN ? winTitle : loseTitle;
     subtitle.text = current == GameStateManager.GameState.WIN ? winSubtitle : loseSubtitle;
 }
示例#24
0
        private void Update()
        {
            //Get the game state
            GameStateManager.GameState GAME_STATE = GameStateManager.STATE;

            //Always be able to reset
            if (Input.GetKey(KeyCode.Alpha1) && Input.GetKey(KeyCode.Alpha9))
            {
                GAME_STATE = GameStateManager.GameState.Reset;
            }

            //Handle each game state
            switch (GAME_STATE)
            {
            case GameStateManager.GameState.Reset:

                EmailProgressNum = 0;
                m_ProgressConfig.m_CurrentProgress = EmailProgressNum;
                m_ProgressConfig.FailureCount      = 0;
                m_ProgressConfig.TRexScore         = 0;
                m_ProgressConfig.StegosaursScore   = 0;
                m_ProgressConfig.PterosaursScore   = 0;
                GameSaveManager.ClearStoredScore();


                GameStateManager.SetCurrentState(GameStateManager.GameState.MailReading);

                SceneManager.LoadScene(firstSceneName);

                break;

            case GameStateManager.GameState.MailReading:
                if (!stateInited)
                {
                    EmailProgressNum = m_ProgressConfig.m_CurrentProgress;
                    ExtractStoredScore();
                    EnableProceedToWork(false);
                    ShowCurrentMail();
                    stateInited = true;
                }

                if (m_EmailManager.isEmailClosed)
                {
                    EnableProceedToWork(true);
                }

                break;

            case GameStateManager.GameState.SavingProgress:
                if (!stateInited)
                {
                    EmailProgressNum++;
                    m_ProgressConfig.m_CurrentProgress = EmailProgressNum;
                    m_ProgressConfig.SetDirty();
                    stateInited = true;
                }
                break;

            case GameStateManager.GameState.Gaming:
                if (!stateInited)
                {
                    //EmailProgressNum++;
                    stateInited = true;
                }
                break;

            case GameStateManager.GameState.Restarting:

                SceneManager.LoadScene("MainFrame");
                GameStateManager.SetCurrentState(GameStateManager.GameState.Reset);
                break;

            case GameStateManager.GameState.Ending:
                break;

            default:
                break;
            }
        }
示例#25
0
 public void killGhost()
 {
     ghostState = GameStateManager.GameState.Dead;
     animator.SetTrigger("Dead");
 }
示例#26
0
 public void SetGameState(GameStateManager.GameState inGameState)
 {
     this.pGameState = GameStateManager.GetState(inGameState);
 }
示例#27
0
    // Update is called once per frame
    void Update()
    {
        // Debug.Log("Ghost 1's state: " + ghostState);

        rend.sortingOrder = 250 - (int)(gameObject.transform.position.y * 20);

        if (prevState != ghostState)
        {
            animator.SetInteger("GameState", (int)ghostState);
            prevState = ghostState;

            if (ghostState == GameStateManager.GameState.Walking)
            {
                speed = 7.2f;
            }
            if (ghostState == GameStateManager.GameState.Scared || ghostState == GameStateManager.GameState.Recovering)
            {
                speed = 6f;
            }
        }

        // Debug.Log("Up: " + prevAdjacentWalkable[0].ToString() + ", Down: " + prevAdjacentWalkable[1].ToString() + ", Right: " + prevAdjacentWalkable[2].ToString() + ", Left: " + prevAdjacentWalkable[3].ToString());
        if (ghostState == GameStateManager.GameState.Dead)
        {
            if (!tweener.TweenExists())
            {
                if (column > 9 && row > 11) // If ghost is in spawn area…
                {
                    row = spawnRow; column = spawnColumn;
                    gameObject.transform.position = new Vector2(xSpawnPosition * dis, ySpawnPosition * dis);
                    // Debug.Log("Ghost in spawn without tween");
                    if (state.state == GameStateManager.GameState.Scared)
                    {
                        if (state.ghostsAreRecovering)
                        {
                            ghostState = GameStateManager.GameState.Recovering;
                        }
                        else
                        {
                            ghostState = GameStateManager.GameState.Scared;
                        }
                    }
                    else
                    {
                        ghostState = GameStateManager.GameState.Walking;
                    }
                }
                else
                {
                    // Debug.Log("Ghost tweened back to spawn");
                    tweener.AddTween(gameObject.transform, gameObject.transform.position, new Vector2(xSpawnPosition, ySpawnPosition), speed * 0.8f);
                    row = spawnRow; column = spawnColumn;
                }
            }
        }

        if (state.state != GameStateManager.GameState.Intro && ghostState != GameStateManager.GameState.Dead && state.state != GameStateManager.GameState.Dead)
        {
            if (!tweener.TweenExists())
            {
                if ((gameObject.transform.position.x) > 0)
                {
                    hor = 1;
                }
                else
                {
                    hor = -1;
                }
                if ((gameObject.transform.position.y) > 0)
                {
                    ver = 1;
                }
                else
                {
                    ver = -1;
                }

                // gameObject.transform.position = new Vector2(dis * (13.5f - column) * hor, dis * (14.5f - row) * ver);

                if (isAtJunction())
                {
                    setInput();

                    if (lastInput == Direction.Up)
                    {
                        tweener.AddTween(gameObject.transform, gameObject.transform.position, new Vector2(gameObject.transform.position.x, gameObject.transform.position.y + dis), speed);
                        if (lastInput != currentInput)
                        {
                            animator.SetTrigger("Up");
                        }
                        row -= ver;
                        setAdjacent(0, dis);
                        currentInput = lastInput;
                    }

                    else if (lastInput == Direction.Down)
                    {
                        tweener.AddTween(gameObject.transform, gameObject.transform.position, new Vector2(gameObject.transform.position.x, gameObject.transform.position.y - dis), speed);
                        if (lastInput != currentInput)
                        {
                            animator.SetTrigger("Down");
                        }
                        if (row == 14)
                        {
                            row = 13;
                        }
                        else
                        {
                            row += ver;
                        }
                        setAdjacent(0, -dis);
                        currentInput = lastInput;
                    }

                    else if (lastInput == Direction.Right)
                    {
                        if (column == 0 && hor > 0)
                        {
                            gameObject.transform.position = new Vector2(gameObject.transform.position.x * -1, gameObject.transform.position.y);
                        }
                        else
                        {
                            tweener.AddTween(gameObject.transform, gameObject.transform.position, new Vector2(gameObject.transform.position.x + dis, gameObject.transform.position.y), speed);
                            if (lastInput != currentInput)
                            {
                                animator.SetTrigger("Right");
                            }
                            if (column < 13 || hor > 0)
                            {
                                column -= hor;
                            }
                            setAdjacent(dis, 0);
                            currentInput = lastInput;
                        }
                    }

                    else if (lastInput == Direction.Left)
                    {
                        if (column == 0 && hor < 0)
                        {
                            gameObject.transform.position = new Vector2(gameObject.transform.position.x * -1, gameObject.transform.position.y);
                        }
                        else
                        {
                            tweener.AddTween(gameObject.transform, gameObject.transform.position, new Vector2(gameObject.transform.position.x - dis, gameObject.transform.position.y), speed);
                            if (lastInput != currentInput)
                            {
                                animator.SetTrigger("Left");
                            }
                            if (column < 13 || hor < 0)
                            {
                                column += hor;
                            }
                            setAdjacent(-dis, 0);
                            currentInput = lastInput;
                        }
                    }
                }

                else
                {
                    if (currentInput == Direction.Up)
                    {
                        tweener.AddTween(gameObject.transform, gameObject.transform.position, new Vector2(gameObject.transform.position.x, gameObject.transform.position.y + dis), speed);
                        row -= ver;
                        setAdjacent(0, dis);
                    }

                    else if (currentInput == Direction.Down)
                    {
                        tweener.AddTween(gameObject.transform, gameObject.transform.position, new Vector2(gameObject.transform.position.x, gameObject.transform.position.y - dis), speed);
                        if (row == 14)
                        {
                            row = 13;
                        }
                        else
                        {
                            row += ver;
                        }
                        setAdjacent(0, -dis);
                    }

                    else if (currentInput == Direction.Right)
                    {
                        if (column == 0 && hor > 0)
                        {
                            gameObject.transform.position = new Vector2(gameObject.transform.position.x * -1, gameObject.transform.position.y);
                        }
                        else
                        {
                            tweener.AddTween(gameObject.transform, gameObject.transform.position, new Vector2(gameObject.transform.position.x + dis, gameObject.transform.position.y), speed);
                            if (column < 13 || hor > 0)
                            {
                                column -= hor;
                            }
                            setAdjacent(dis, 0);
                        }
                    }

                    else if (currentInput == Direction.Left)
                    {
                        if (column == 0 && hor < 0)
                        {
                            gameObject.transform.position = new Vector2(gameObject.transform.position.x * -1, gameObject.transform.position.y);
                        }
                        else
                        {
                            tweener.AddTween(gameObject.transform, gameObject.transform.position, new Vector2(gameObject.transform.position.x - dis, gameObject.transform.position.y), speed);
                            if (column < 13 || hor < 0)
                            {
                                column += hor;
                            }
                            setAdjacent(-dis, 0);
                        }
                    }
                }
            }
        }
    }
示例#28
0
 public GameEndState(GameStateManager.GameState stateName)
     : base(stateName)
 {
 }