Exemplo n.º 1
0
    public override void OnRefreshWindow()
    {
        _imgIcon.sprite     = ResourceManager.Instance.GetPlayerIcon(0);
        _txtName.text       = UserManager.Instance.RoleName;
        _txtFightScore.text = UserManager.Instance.GetFightScore().ToString();
        _txtVip.text        = "VIP" + UserManager.Instance.VipLevel;
        _txtLevel.text      = "LV." + UserManager.Instance.Level;

        PlayerLevelConfig cfg = PlayerLevelConfigLoader.GetConfig(UserManager.Instance.Level);

        if (cfg != null)
        {
            _txtExp.text = string.Format("{0}/{1}", UserManager.Instance.Exp, cfg.Exp);
            _txtExp.gameObject.SetActive(true);
            _imgExp.fillAmount      = 1.0f * UserManager.Instance.Exp / cfg.Exp;
            _txtHeroLevelLimit.text = cfg.HeroLevelLimit.ToString();
        }
        else
        {
            _txtExp.gameObject.SetActive(false);
            _imgExp.fillAmount = 1;
        }

        _txtUserID.text = UserManager.Instance.EntityID.ToString();
        _txtGuild.text  = GuildManager.Instance.GuildID == 0 ? Str.Get("UI_NONE") : GuildManager.Instance.GuildName;
    }
Exemplo n.º 2
0
    public int GetMaxSP()
    {
        PlayerLevelConfig cfg = PlayerLevelConfigLoader.GetConfig(Level);

        if (cfg != null)
        {
            return(cfg.MaxStamina);
        }

        return(0);
    }
Exemplo n.º 3
0
    public void OnAddUserExp(int exp)
    {
        PlayerLevelConfig cfg = PlayerLevelConfigLoader.GetConfig(Level);

        if (cfg != null)
        {
            if (Exp + exp >= cfg.Exp)
            {
                // 升级的情况由服务端处理
            }
            else
            {
                Exp += exp;
            }
        }
    }
Exemplo n.º 4
0
    private void OnRefreshAttribute()
    {
        _txtPlayName.text    = UserManager.Instance.RoleName;
        _txtPlayGrade.text   = UserManager.Instance.Level.ToString();
        _txtPlayerForce.text = UserManager.Instance.GetFightScore().ToString();

        PlayerLevelConfig cfg = PlayerLevelConfigLoader.GetConfig(UserManager.Instance.Level);

        if (cfg != null && cfg.Exp > 0)
        {
            _imageExpPrg.fillAmount = 1f * UserManager.Instance.Exp / cfg.Exp;
        }
        else
        {
            _imageExpPrg.fillAmount = 1;
        }
    }
Exemplo n.º 5
0
    private void SetInfo(WorldCityInfo info)
    {
        _curInfo = info;
        if (_curInfo == null)
        {
            return;
        }

        const string UNKNOWN = "????";

        _textUserName.text  = _curInfo.UserName;
        _imgUserIcon.sprite = ResourceManager.Instance.GetPlayerIcon(_curInfo.UserIcon);

        _textuserLevel.text      = _curInfo.UserLevel != 0 ? "Lv" + _curInfo.UserLevel : UNKNOWN;
        _textUserFightScore.text = _curInfo.UserFightScore != -1 ? _curInfo.UserFightScore.ToString() : UNKNOWN;

        _textRewardMoney.text = _curInfo.RewardMoney != -1 ?_curInfo.RewardMoney.ToString() : UNKNOWN;
        _textRewardWood.text  = _curInfo.RewardWood != -1 ? _curInfo.RewardWood.ToString() : UNKNOWN;
        _textRewardStone.text = _curInfo.RewardStone != -1 ? _curInfo.RewardStone.ToString() : UNKNOWN;

        if (_curInfo.RewardGold > 0)
        {
            _textRewardGoldText.gameObject.SetActive(true);
            _textRewardGold.text = _curInfo.RewardGold.ToString();
        }
        else
        {
            _textRewardGoldText.gameObject.SetActive(false);
        }

        // TODO 根据品阶设置背景
        if (_curInfo.HeroInfoList.Count > 0)
        {
            _hero1Bg.gameObject.SetActive(true);
            _hero1Icon.gameObject.SetActive(true);
            _hero1Icon.sprite = ResourceManager.Instance.GetHeroIcon(_curInfo.HeroInfoList[0].heroCfgID);
        }
        else
        {
            _hero1Bg.gameObject.SetActive(false);
            _hero1Icon.gameObject.SetActive(false);
        }

        if (_curInfo.HeroInfoList.Count > 1)
        {
            _hero2Bg.gameObject.SetActive(true);
            _hero2Icon.gameObject.SetActive(true);
            _hero2Icon.sprite = ResourceManager.Instance.GetHeroIcon(_curInfo.HeroInfoList[1].heroCfgID);
        }
        else
        {
            _hero2Bg.gameObject.SetActive(false);
            _hero2Icon.gameObject.SetActive(false);
        }

        if (_curInfo.HeroInfoList.Count > 2)
        {
            _hero3Bg.gameObject.SetActive(true);
            _hero3Icon.gameObject.SetActive(true);
            _hero3Icon.sprite = ResourceManager.Instance.GetHeroIcon(_curInfo.HeroInfoList[2].heroCfgID);
        }
        else
        {
            _hero3Bg.gameObject.SetActive(false);
            _hero3Icon.gameObject.SetActive(false);
        }

        // 可以刷新
        if (!_curInfo.IsMyCity() && _curInfo.CouldRefresh())
        {
            _btnSwitch.gameObject.SetActive(true);
        }
        else
        {
            _btnSwitch.gameObject.SetActive(false);
        }

        PlayerLevelConfig cfg = PlayerLevelConfigLoader.GetConfig(UserManager.Instance.Level);

        _txtAttackCost.text = cfg.AttackCost.ToString();
    }
Exemplo n.º 6
0
    // 攻击
    public void OnClickAttack()
    {
        PlayerLevelConfig cfg = PlayerLevelConfigLoader.GetConfig(UserManager.Instance.Level);

        WorldManager.Instance.RequestAttack(_curInfo.MapPosition, _curInfo.UserEntityID, _curInfo.IsNpc, cfg.AttackCost);
    }
Exemplo n.º 7
0
    void OnGUI()
    {
        const int BUTTON_WIDTH  = 100;
        const int BUTTON_HEIGHT = 60;
        const int OFFSET        = 10;

        if (!Game.Instance.IsInGame && !Game.Instance.IsOffline)
        {
            return;
        }

        if (_hideGM)
        {
            if (GUI.Button(new Rect(100, 0, BUTTON_WIDTH, BUTTON_HEIGHT), "显示"))
            {
                _hideGM = !_hideGM;
            }
            return;
        }

        float x = 0;
        float y = 0;

        if (GUI.Button(new Rect(x, y, BUTTON_WIDTH, BUTTON_HEIGHT), "显示GM命令"))
        {
            _showGM = !_showGM;
        }

        x += BUTTON_WIDTH + OFFSET;
        if (GUI.Button(new Rect(x, y, BUTTON_WIDTH, BUTTON_HEIGHT), "隐藏"))
        {
            _hideGM = !_hideGM;
        }

        if (!_showGM)
        {
            return;
        }

        y += BUTTON_HEIGHT + OFFSET;
        if (GUI.Button(new Rect(x, y, BUTTON_WIDTH, BUTTON_HEIGHT), "创建英雄"))
        {
            foreach (var item in HeroConfigLoader.Data)
            {
                GMManager.Instance.RequestCreateHero(item.Key);
                break;
            }
        }

        x += BUTTON_WIDTH + OFFSET;
        if (GUI.Button(new Rect(x, y, BUTTON_WIDTH, BUTTON_HEIGHT), "玩家升级+1"))
        {
            PlayerLevelConfig cfg = PlayerLevelConfigLoader.GetConfig(UserManager.Instance.Level);
            GMManager.Instance.RequestPlayerUpLevel(cfg.Exp);
        }

        x += BUTTON_WIDTH + OFFSET;
        if (GUI.Button(new Rect(x, y, BUTTON_WIDTH, BUTTON_HEIGHT), "玩家升级+10"))
        {
            int exp = 0;
            for (int i = UserManager.Instance.Level; i < UserManager.Instance.Level + 10; ++i)
            {
                PlayerLevelConfig cfg = PlayerLevelConfigLoader.GetConfig(i, false);
                if (cfg == null)
                {
                    break;
                }
                exp += cfg.Exp;
            }

            GMManager.Instance.RequestPlayerUpLevel(exp);
        }
        x += BUTTON_WIDTH + OFFSET;
        if (GUI.Button(new Rect(x, y, BUTTON_WIDTH, BUTTON_HEIGHT), "大富翁"))
        {
            if (Game.Instance.IsOffline)
            {
                UserManager.Instance.Money = 99999999;
                UserManager.Instance.Gold  = 99999999;
                UserManager.Instance.Wood  = 99999999;
                UserManager.Instance.Stone = 99999999;
            }
            else
            {
                GMManager.Instance.RequestAddGood(GameConfig.ITEM_CONFIG_ID_MONEY, 100000);
                GMManager.Instance.RequestAddGood(GameConfig.ITEM_CONFIG_ID_WOOD, 100000);
                GMManager.Instance.RequestAddGood(GameConfig.ITEM_CONFIG_ID_STONE, 100000);
                GMManager.Instance.RequestAddGood(GameConfig.ITEM_CONFIG_ID_GOLD, 100000);
            }
        }
        x += BUTTON_WIDTH + OFFSET;
        if (GUI.Button(new Rect(x, y, BUTTON_WIDTH, BUTTON_HEIGHT), "穷B"))
        {
            if (Game.Instance.IsOffline)
            {
                UserManager.Instance.Money = 0;
                UserManager.Instance.Gold  = 0;
                UserManager.Instance.Wood  = 0;
                UserManager.Instance.Stone = 0;
            }
            else
            {
                UseItem(GameConfig.ITEM_CONFIG_ID_MONEY, 100000);
                UseItem(GameConfig.ITEM_CONFIG_ID_WOOD, 100000);
                UseItem(GameConfig.ITEM_CONFIG_ID_STONE, 100000);
                UseItem(GameConfig.ITEM_CONFIG_ID_GOLD, 100000);
            }
        }

        x  = 0;
        y += BUTTON_HEIGHT + OFFSET;
        if (GUI.Button(new Rect(x, y, BUTTON_WIDTH, BUTTON_HEIGHT), "添加全部英雄"))
        {
            if (Game.Instance.IsOffline)
            {
                TestLocalData.Instance.AddAllHero();
            }
            else
            {
                StartCoroutine(GetAllHero());
            }
        }

        y += BUTTON_HEIGHT + OFFSET;
        if (GUI.Button(new Rect(x, y, BUTTON_WIDTH, BUTTON_HEIGHT), "添加全部物品"))
        {
            if (Game.Instance.IsOffline)
            {
                TestLocalData.Instance.AddAllItem();
            }
            else
            {
                StartCoroutine(GetAllItem());
            }
        }

        x += BUTTON_WIDTH + OFFSET;
        if (GUI.Button(new Rect(x, y, BUTTON_WIDTH, BUTTON_HEIGHT), "请求商品列表"))
        {
            //ShopManager.Instance.RequestShopInfo();
        }

        x  = 0;
        y += BUTTON_HEIGHT + OFFSET;
        if (GUI.Button(new Rect(x, y, BUTTON_WIDTH, BUTTON_HEIGHT), "添加全部建筑"))
        {
            if (Game.Instance.IsOffline)
            {
                TestLocalData.Instance.AddAllBuilding();
                UIManager.Instance.RefreshWindow <UICityView>();
            }
        }

        x += BUTTON_WIDTH + OFFSET;
        if (GUI.Button(new Rect(x, y, BUTTON_WIDTH, BUTTON_HEIGHT), "添加全部兵种"))
        {
            if (Game.Instance.IsOffline)
            {
                TestLocalData.Instance.AddAllSoldier();
            }
        }

        x  = 0;
        y += BUTTON_HEIGHT + OFFSET;
        if (GUI.Button(new Rect(x, y, BUTTON_WIDTH, BUTTON_HEIGHT), "掉线"))
        {
        }

        x += BUTTON_WIDTH + OFFSET;
        if (GUI.Button(new Rect(x, y, BUTTON_WIDTH, BUTTON_HEIGHT), "战斗开始"))
        {
            BattleManager.Instance.StartBattle(1, LogicBattleType.PVP);
        }

        x += BUTTON_WIDTH + OFFSET;
        if (GUI.Button(new Rect(x, y, BUTTON_WIDTH, BUTTON_HEIGHT), "战斗结束"))
        {
            BattleManager.Instance.OnBattleFinish(true);
        }

        x += BUTTON_WIDTH + OFFSET;
        if (GUI.Button(new Rect(x, y, BUTTON_WIDTH, BUTTON_HEIGHT), "返回主场景"))
        {
            BattleManager.Instance.ChangeToMainScene();
        }

        x  = 0;
        y += BUTTON_HEIGHT + OFFSET;
        if (GUI.Button(new Rect(x, y, BUTTON_WIDTH, BUTTON_HEIGHT), "添加城池"))
        {
            if (Game.Instance.IsOffline)
            {
                TestLocalData.Instance.AddAllCity();
                UIManager.Instance.RefreshWindow <UIWorldMapView>();
            }
        }

        x += BUTTON_WIDTH + OFFSET;
        if (GUI.Button(new Rect(x, y, BUTTON_WIDTH, BUTTON_HEIGHT), "收集资源"))
        {
            WorldManager.Instance.RequestCollectResource();
        }
    }