public CheckerboardControl(GameObject gameObject)
 {
     m_GameObject = gameObject;
     m_View       = new CheckerboardView(gameObject.transform);
     m_View.MoveAnimationFinished += OnAnimationFinish;
     m_View.TouchDropEvent        += OnTouchDropEvent;
     m_Model = new CheckerboardModel();
     m_View.PlayZoomAnimation(m_Model.NodeMatrix);
     m_GameRecord = new GameRecord();
     m_GameRecord.PushFrame(m_Model.NodeMatrix);
     SerializeUtil.DataSaveWithPath(m_GameRecord, PathUtil.CurrentRecordPath);
 } // end CheckerboardControl
Exemple #2
0
    } // end OnExit

    private void OnSelect(int index)
    {
        string path = PathUtil.GetRecordPathWithIndex(index);

        if (string.IsNullOrEmpty(path) || !File.Exists(PathUtil.CurrentRecordPath))
        {
            return;
        }
        // end if
        File.Copy(PathUtil.CurrentRecordPath, path, true);
        m_RecordList.SetRecordNameWithIndex(index, System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
        SerializeUtil.DataSaveWithPath(m_RecordList, PathUtil.RecordListPath);
        GameManager.Instance.ContinueGame(PathUtil.CurrentRecordPath);
    } // end OnSelect
    }         // end OnTouchDropEvent

    private void OnAnimationFinish(object sender, EventArgs args)
    {
        if (null != m_ScoreChangedEventHandler)
        {
            m_ScoreChangedEventHandler(this, new ScoreChangedEventArgs(m_Model.Score));
        }
        // end if
        m_GameRecord.PushFrame(m_Model.NodeMatrix);
        m_Model.PushNewNumber();
        m_View.PlayZoomAnimation(m_Model.NodeMatrix);
        m_GameRecord.PushFrame(m_Model.NodeMatrix);
        SerializeUtil.DataSaveWithPath(m_GameRecord, PathUtil.CurrentRecordPath);
        if (m_Model.IsGameOver() && null != m_GameOverEventHandler)
        {
            m_GameOverEventHandler(this, EventArgs.Empty);
        }
        // end if
    } // end OnAnimationFinish
    public void Undo()
    {
        if (!Global.Interactable || m_View.IsPlayingAnimation)
        {
            return;
        }
        // end if
        Matrix <NodeModel> matrix = m_GameRecord.PreviousFrame;

        matrix = m_GameRecord.PreviousFrame;
        if (null == matrix)
        {
            Debug.LogWarning("Have not record!");
            return;
        } // end if
        m_Model.NodeMatrix = matrix;
        m_View.PlayZoomAnimation(m_Model.NodeMatrix);
        SerializeUtil.DataSaveWithPath(m_GameRecord, PathUtil.CurrentRecordPath);
        if (null != m_ScoreChangedEventHandler)
        {
            m_ScoreChangedEventHandler(this, new ScoreChangedEventArgs(m_Model.Score));
        }
        // end if
    } // end Undo