Ejemplo n.º 1
0
        public void OnLogin()
        {
            int  curExp  = Data.Exp;
            int  NeedExp = RewardHelper.EXPNeeded(Data.Level);
            bool LevelUp = curExp >= NeedExp;

            if (LevelUp)
            {
                Data.Exp = 0;
                int NextLevel = Data.Level + 1;
                if (NextLevel < 100)
                {
                    Data.Level    = NextLevel;
                    LevelUpNotify = true;
                }
            }
            RankinngOBJ Rdata = RankingManager.GetPlayer(this);

            if (Rdata != null)
            {
                Deaths         = Rdata.Deaths;
                Kills          = Rdata.Deaths;
                League         = Rdata.League;
                LeaguePoints   = Rdata.LeaguePoints;
                GameCount      = Rdata.GameCount;
                LeaguePosition = Rdata.RankNo <= 100 ? (byte)Rdata.RankNo : (byte)101;
            }
        }
Ejemplo n.º 2
0
    public NPC(GameObject root, Value v)
    {
        this.config = v;
        var npcType = this.config.TryGet <string>("NPC类型");

        Debug.Log(npcType);
        var prefab = "Prefabs/room/NPC";

        if (npcType == "传送门")
        {
            prefab = "Prefabs/room/传送门";
        }

        this.go = Game.CreatePrefab(root, new GameObjectItem
        {
            name   = v.name,
            x      = this.config.TryGet <int>("x"),
            y      = this.config.TryGet <int>("y"),
            prefab = prefab,
        });
        this.go.GetComponentInChildren <Text>().text = v.name;
        if (npcType == "传送门")
        {
            //增加传送事件
            this.go.GetComponent <Button>().onClick.AddListener(() =>
            {
                var buttonSelf = UnityEngine.EventSystems.EventSystem.current.currentSelectedGameObject;
                //根据传送门按钮name,查找要传送的地图

                var buttonConfig       = User.GetConfigByName(buttonSelf.name);
                var targetRoomPosition = buttonConfig.TryGet <string>("目标传送门");
                var targetConfig       = User.GetConfigByName(targetRoomPosition);
                var targetRoom         = targetConfig.TryGet <string>("房间");
                Debug.Log(string.Format("传送至{0} : {1}", targetRoom, targetRoomPosition));
                var g = GameObject.Find("UI").transform.Find("挂机按钮");
                Debug.Log(g);
                if (g != null)
                {
                    if (targetRoom == "郊外")
                    {
                        g.gameObject.SetActive(true);
                    }
                    else
                    {
                        g.gameObject.SetActive(false);
                    }
                }
                MapManager.curMapManager.BuildRoom(targetRoom);
            });
        }

        if (npcType == "NPC")
        {
            this.go.GetComponentInChildren <Button>().onClick.AddListener(() =>
            {
                Game.ShowMessage(this.config.TryGet <string>("提示"), messageType: 1);
            });
        }

        if (npcType == "Fight")
        {
            this.go.GetComponentInChildren <Button>().onClick.AddListener(() =>
            {
                FightScene.Create(root);
            });
        }

        if (npcType == "DrawCard")
        {
            this.go.GetComponentInChildren <Button>().onClick.AddListener(() =>
            {
                //创建预制体抽卡
                var bagGO = GameObject.Find("抽卡");
                if (bagGO == null)
                {
                    var top      = GameObject.Find("Top");
                    var drawCard = Game.CreatePrefab(top, new GameObjectItem()
                    {
                        type   = 1,
                        name   = "抽卡",
                        prefab = "Prefabs/Room/DrawCard",
                    });

                    var oneButton = Game.Find <Button>("DrawOne");
                    oneButton.onClick.AddListener(() =>
                    {
                        var res = User.HttpSend <Prop[]>("/game/drawCard", new
                        {
                        });
                        RewardHelper.ShowRewards(res);
                        Debug.Log(res);
                    });

                    var tenButton = Game.Find <Button>("DrawTen");
                    tenButton.onClick.AddListener(() =>
                    {
                        var res = User.HttpSend <Prop[]>("/game/drawCardTen", new
                        {
                        });
                        RewardHelper.ShowRewards(res);
                        Debug.Log(res);
                    });

                    var drawCardBack = Game.Find <Button>("DrawCardBack");
                    drawCardBack.onClick.AddListener(() =>
                    {
                        GameObject.Destroy(drawCard);
                    });
                }
            });
        }
    }