예제 #1
0
    void Start()
    {
        // Init Walkers
        var walkerDatas = DataManager.instance.walkerDatas;

        for (int i = 0; i < walkerDatas.Count; ++i)
        {
            var walkerObj  = Instantiate(GameManager.instance.walkerPrefab);
            var walkerCtrl = walkerObj.GetComponent <Walker> ();
            walkerCtrl.Init(walkerDatas [i]);
            walkerCtrl.transform.position = GetSpwanPoint("Walker" + i.ToString());
        }

        // Init Xians
        // var xianDatas =

        // TODO
        // Create Model
        if (MainScene.isLoadModel == false)
        {
            MainScene.isLoadModel = true;

            for (int i = 0; i < DataManager.instance.xianDatas.Count; i++)
            {
                XianData datXian = DataManager.instance.xianDatas[i];
                MXian.Create(datXian);
            }
        }
    }
예제 #2
0
    public static MXian Unlock(int xianId)
    {
        // Debug.Assert(IsUnlockXian(xianId) == false, "CHECK > " + xianId.ToString());

        XianData datXian = new XianData();

        datXian.id = xianId;
        datXian.lv = -1;
        DataManager.instance.xianDatas.Add(datXian);
        DataManager.instance.MarkSaveData();

        return(MXian.Create(datXian));
    }
예제 #3
0
    public static MXian Create(XianData datXian)
    {
        MXian mx = Get(datXian.id);

        if (mx != null)
        {
            return(mx);
        }

        mx = new MXian(datXian.id);
        mxianList.Add(mx);
        return(mx);
    }
예제 #4
0
    public void OnClickHandleButton()
    {
        if (m_btnStatus == ButtonStatus.Lock)
        {
        }
        else if (m_btnStatus == ButtonStatus.WaitKaiGuang)
        {
            MXian mx = MXian.Get(m_xianId);
            Debug.Assert(mx != null, "CHECK");

            string msg;
            if (mx.TryKaiGuang(out msg))
            {
                textLv.text = "Lv:" + (mx.lv + 1).ToString();

                this.UpdateButtonStatus();
            }
            else
            {
                Debug.Log("kaiguang fail > " + msg);
            }
        }
        else if (m_btnStatus == ButtonStatus.WaitGongFeng)
        {
            MXian mx = MXian.Get(m_xianId);
            Debug.Assert(mx != null, "CHECK");

            string msg;
            if (mx.TryGongFeng(out msg))
            {
                textLv.text   = "Lv:" + (mx.lv + 1).ToString();
                textCoin.text = "";

                this.UpdateButtonStatus();
            }
            else
            {
                Debug.Log("gongfeng fail > " + msg);
            }
        }
    }
예제 #5
0
    void Update()
    {
        // state changed
        if (m_lastState != state)
        {
            m_lastState = state;

            if (state == State.Start)
            {
                m_justiceTeam.StartBattle();
                m_evilTeam.StartBattle();
            }
            else if (state == State.Battle)
            {
                m_attackTeam.StartAttackTurn();
            }
            else if (state == State.End)
            {
                // get reward
                var levelConfig = GameManager.instance.levelConfigs [m_curLevelIndex];
                DataManager.instance.coin += levelConfig.coin;
                DataManager.instance.exp  += levelConfig.exp;
                if (MXian.IsValidId(levelConfig.unlockXianId))
                {
                    MXian.Unlock(levelConfig.unlockXianId);
                }

                menuBattleEnd.SetActive(true);
                var menuCtrl = menuBattleEnd.GetComponent <MenuBattleEnd> ();
                if (menuCtrl != null)
                {
                    menuCtrl.FinishLevel(m_curLevelIndex);
                }
            }
        }
    }