Exemplo n.º 1
0
    void RPC_S2C_ASB_LevelUpStart(uLink.BitStream stream, uLink.NetworkMessageInfo info)
    {
        CSAssemblyData recordData = (CSAssemblyData)_ColonyObj._RecordData;

        recordData.m_CurUpgradeTime = stream.Read <float>();
        recordData.m_UpgradeTime    = stream.Read <float>();
        string roleName = stream.Read <string>();
        bool   success  = stream.Read <bool>();

        if (m_Entity == null)
        {
            Debug.LogWarning("entity not ready");
            return;
        }

        CSAssembly csAssembly = m_Entity as CSAssembly;

        csAssembly.StartUpgradeCounter(recordData.m_CurUpgradeTime, recordData.m_UpgradeTime);
        if (CSUI_MainWndCtrl.Instance.AssemblyUI != null && success)
        {
            CSUI_MainWndCtrl.Instance.AssemblyUI.UpgradeStartSuccuss(csAssembly, roleName);
        }
    }
Exemplo n.º 2
0
    void OnUpgradeBtn()
    {
        if (PeCreature.Instance.mainPlayer == null)
        {
            return;
        }

        ItemPackage accessor = PeCreature.Instance.mainPlayer.GetCmpt <PlayerPackageCmpt>().package._playerPak;

        //check start
        bool canUpgrade = true;
        bool bEnough    = true;

        foreach (CSUI_MaterialGrid mg in m_MatGrids)
        {
            if (mg.ItemID != 0)
            {
                mg.ItemNum = playerPackageCmpt.package.GetCount(mg.ItemID);
                if (mg.ItemNum < mg.NeedCnt)
                {
                    bEnough = false;
                    new PeTipMsg(PELocalization.GetString(821000001), PeTipMsg.EMsgLevel.Warning);
                    break;
                }
            }
        }

        if (bEnough && !m_Assembly.isUpgrading && !m_Assembly.isDeleting)
        {
            canUpgrade = true;
        }
        else
        {
            canUpgrade = false;
        }

        if (m_Assembly.Level == m_Assembly.GetMaxLevel())
        {
            canUpgrade = false;
        }
        if (!canUpgrade)
        {
            return;
        }
        //check end

        if (!GameConfig.IsMultiMode)
        {
            foreach (CSUI_MaterialGrid mg in m_MatGrids)
            {
                if (mg.ItemID > 0)
                {
                    accessor.Destroy(mg.ItemID, mg.NeedCnt);
                    //package.DeleteItemWithItemID(mg.ItemID, mg.NeedCnt);
                    CSUI_MainWndCtrl.CreatePopupHint(mg.transform.position, this.transform, new Vector3(10, -2, -5), " - " + mg.NeedCnt.ToString(), false);
                }
            }

            m_Assembly.StartUpgradeCounter();

            CSUI_MainWndCtrl.ShowStatusBar(CSUtils.GetNoFormatString(UIMsgBoxInfo.mStartToUpgrade.GetString(), m_Entity.Name));
        }
        else
        {
            m_Assembly._ColonyObj._Network.ASB_LevelUp();
        }
    }