Пример #1
0
        public override void StartTask()
        {
            base.StartTask();
            // ON CLIENT RECEIVE SKILLS
            this.RegisterEvent("clientReceiveSkills", this.OnClientReceiveSkills);
            // ON CLIENT SET UP SKILL COMPLETED
            this.RegisterEvent("clientCompletedSetupSkill", this.OnClientCompleteSetupSkills);
            // CHAT
            this.RegisterEvent("clientReceiveChat", this.OnClientReceiveChat);
            // Fighting
            this.RegisterEvent("clientWaitPlayerQueue", this.OnClientWaitPlayerQueue);
            this.RegisterEvent("clientReceiveResultPlayerQueue", this.OnClientReceiveResultPlayerQueue);
            this.RegisterEvent("clientCancelPlayerQueue", this.OnClientCancelPlayerQueue);
            // ENERGY
            this.RegisterEvent("clientUpdateEnergy", this.OnClientUpdateEnergy);
            // SKILL DATA
            var skillList = CTaskUtil.Get(CTaskUtil.SKILL_DATA_LIST) as List <CSkillData>;

            this.m_LobbyManager = CUILobbyManager.GetInstance();
            this.m_LobbyManager.OnSetupHeroSkill("Normal Attack", 3, skillList, null);
            this.m_UpdateEnergyTimer = this.m_UpdateEnergyPerSecond;
            // HERO DATA
            var heroData = CTaskUtil.Get(CTaskUtil.HERO_DATA) as CHeroData;

            this.m_LobbyManager.UpdateEnergyText(heroData.currentEnergy.ToString(), heroData.maxEnergy.ToString());
        }
Пример #2
0
        protected virtual IEnumerator HandleSpawnCharacter()
        {
            var heroData = CTaskUtil.Get(CTaskUtil.HERO_DATA) as CHeroData;

            this.m_CharacterController = Instantiate(Resources.Load <CHeroController>("CharacterPrefabs/" + heroData.objectModel));
            yield return(this.m_CharacterController);

            // Init Events
            this.m_CharacterController.AddAction("StartIdleState", this.OnPlayerStartRollDice);
            this.m_CharacterController.AddAction("MovedBlockState", this.OnPlayerMovedToBlock);
            // INIT DATA
            this.m_CharacterController.SetData(heroData);
            this.m_CharacterController.SetActive(true);
            this.m_CharacterController.Init();
            // SET CURRENT BLOCK
            var currentBlock = this.m_MapManager.CalculateCurrentBlock(this.m_CharacterController.GetStep());

            this.m_CharacterController.currentBlock = currentBlock;
            this.m_CharacterController.targetBlock  = currentBlock;
            this.m_CharacterController.SetPosition(currentBlock.GetMovePointPosition());
            // LOADING COMPLETED
            this.m_LoadingCompleted = true;
            if (this.OnEventLoadingCompleted != null)
            {
                this.OnEventLoadingCompleted();
            }
            CUIGameManager.Instance.OnLoadCharacterInfo(this.m_CharacterController, false);
            CUIGameManager.Instance.OnUpdateCurrentEnergy(heroData.currentEnergy, heroData.maxEnergy);
            CUIGameManager.Instance.OnUpdateCurrentGold(heroData.currentGold);
        }
Пример #3
0
        public virtual void OnClientSelectedHero(int index, string name)
        {
            var heroesTemplate = CTaskUtil.Get(CTaskUtil.HERO_TEMPLATES) as Dictionary <string, CCharacterData>;
            var heroType       = heroesTemplate.Keys.ToList() [index];

            this.OnClientCreateHero(heroType, name);
        }
Пример #4
0
        public virtual void OnHeroAlreadySetupSkill(List <CSkillData> skillDatas)
        {
            if (this.m_UserManager.IsConnected() == false)
            {
                return;
            }
            var heroData = CTaskUtil.Get(CTaskUtil.HERO_DATA) as CHeroData;

            heroData.characterSkillSlots = new CSkillData[skillDatas.Count];
            for (int i = 0; i < skillDatas.Count; i++)
            {
                heroData.characterSkillSlots [i] = skillDatas [i];
            }
            var dictData    = new Dictionary <string, string> ();
            var setupSkills = "";

            for (int i = 0; i < skillDatas.Count; i++)
            {
                var skillData = skillDatas [i];
                setupSkills += skillData.objectName + (i < skillDatas.Count - 1 ? "," : "");
            }
            dictData ["skills"] = setupSkills;
            var jsonSend = JSONObject.Create(dictData);

            this.m_UserManager.Emit("clientSetupSkills", jsonSend);
        }
Пример #5
0
        public virtual void SetupHeroItem()
        {
            this.m_HeroTemplates = CTaskUtil.Get(CTaskUtil.HERO_TEMPLATES) as Dictionary <string, CCharacterData>;
            this.m_HeroPage.gameObject.SetActive(false);
            var guild = Guid.NewGuid().ToString();

            this.m_HeroNameInputField.text = "Player" + guild.Substring(guild.Length - 5);
            if (this.m_HeroTemplates.Count > 0)
            {
                foreach (var item in this.m_HeroTemplates)
                {
                    var itemInstant = Instantiate(this.m_HeroItemPrefab);
                    var itemData    = item.Value;
                    itemInstant.SetupHeroItem(itemData.objectAvatar);
                    itemInstant.gameObject.SetActive(true);
                    itemInstant.transform.SetParent(this.m_HeroItemRoot.transform);
                }
            }
            this.m_HeroPage.gameObject.SetActive(true);
            this.m_HeroItemPrefab.gameObject.SetActive(false);
            this.m_HeroSubmitButton.onClick.RemoveAllListeners();
            this.m_HeroSubmitButton.onClick.AddListener(() => {
                var heroIndex = this.m_HeroPage.CurrentPage;
                var heroName  = this.m_HeroNameInputField.text;
                if (this.OnEventSubmitHero != null)
                {
                    this.OnEventSubmitHero(heroIndex, heroName);
                    CUICustomManager.Instance.ActiveLoading(true);
                }
            });
        }
Пример #6
0
        public virtual void OnClientSetupLobbyScene(JSONObject receiveData)
        {
            // HERO DATA
            var isHeroData = receiveData.HasField("heroData");

            this.currentHero = CTaskUtil.Get(CTaskUtil.HERO_DATA) as CHeroData;
            if (isHeroData)
            {
                var heroDataJson = receiveData.GetField("heroData").ToString();
                this.currentHero = TinyJSON.JSON.Load(heroDataJson).Make <CHeroData> ();
            }
            CTaskUtil.Set(CTaskUtil.HERO_DATA, this.currentHero);
            // SKILL DATA
            var isSkillData = receiveData.HasField("skillDatas");

            if (isSkillData)
            {
                var skillList    = receiveData.GetField("skillDatas").list;
                var tmpSkillList = new List <CSkillData>();
                for (int i = 0; i < skillList.Count; i++)
                {
                    var objectStr = skillList [i].ToString();
                    var skillData = TinyJSON.JSON.Load(objectStr).Make <CSkillData> ();
                    tmpSkillList.Add(skillData);
                }
                CTaskUtil.Set(CTaskUtil.SKILL_DATA_LIST, tmpSkillList);
            }
        }
Пример #7
0
        protected virtual void OnClientSetupPlayScene(JSONObject receiveData)
        {
            // HERO DATA
            var isHeroData = receiveData.HasField("heroData");

            this.currentHero = CTaskUtil.Get(CTaskUtil.HERO_DATA) as CHeroData;
            if (isHeroData)
            {
                var heroDataJson = receiveData.GetField("heroData").ToString();
                this.currentHero = TinyJSON.JSON.Load(heroDataJson).Make <CHeroData> ();
            }
            CTaskUtil.Set(CTaskUtil.HERO_DATA, this.currentHero);
        }
        // ON CHARACTER DEATH OR INACTIVE
        protected virtual void OnCharacterInactive(object[] args)
        {
            var currentHero = CTaskUtil.Get(CTaskUtil.HERO_DATA) as CHeroData;
            var closerCtrl  = args [0] as CCharacterController;

            if (currentHero.uID == closerCtrl.GetData().uID)
            {
                this.m_MiniGameTask.OnClientClosedBattle();
            }
            else
            {
                this.PrintBattleLog(closerCtrl.GetData().uID);
            }
        }
 // START LOAD CHARACTER
 public virtual void StartLoading()
 {
     this.m_MiniFightingData = CTaskUtil.Get(CTaskUtil.MINI_FIGHTING_DATA) as CMiniFightingData;
     // LOAD PLAYER CONTROLLER
     StartCoroutine(this.HandleSpawnCharacter(this.m_MiniFightingData.playerData,
                                              this.m_PlayerSpawnPoint, (ctrl) => {
         this.m_PlayerController = ctrl;
     }));
     // LOAD ENEMY CONTROLLER
     StartCoroutine(this.HandleSpawnCharacter(this.m_MiniFightingData.enemyData,
                                              this.m_EnemySpawnPoint, (ctrl) => {
         this.m_EnemyController = ctrl;
     }));
     // LOAD SEED
     UnityEngine.Random.InitState(this.m_MiniFightingData.randomSeed);
 }
Пример #10
0
        public virtual void OnClientEndFighting(string winnerId, string closerId)
        {
            if (this.m_UserManager.IsConnected() == false)
            {
                return;
            }
            var miniFightingData = CTaskUtil.Get(CTaskUtil.MINI_FIGHTING_DATA) as CMiniFightingData;
            var dictData         = new Dictionary <string, string> ();

            dictData ["isoTime"]    = miniFightingData.isoTime;
            dictData ["winnerId"]   = winnerId;
            dictData ["closerId"]   = closerId;
            dictData ["randomSeed"] = miniFightingData.randomSeed.ToString();
            var jsonSend = JSONObject.Create(dictData);

            this.m_UserManager.Emit("clientEndMiniFightingGame", jsonSend);
        }
Пример #11
0
        protected virtual void OnClientSetupCreateHeroScene(JSONObject receiveData)
        {
            // HERO DATA
            var isHeroData = receiveData.HasField("heroData");

            this.currentHero = CTaskUtil.Get(CTaskUtil.HERO_DATA) as CHeroData;
            if (isHeroData)
            {
                var heroDataJson = receiveData.GetField("heroData").ToString();
                this.currentHero = TinyJSON.JSON.Load(heroDataJson).Make <CHeroData> ();
            }
            CTaskUtil.Set(CTaskUtil.HERO_DATA, this.currentHero);
            // HEROES TEMPLATE
            var isHeroTemplate = receiveData.HasField("heroesTemplate");
            Dictionary <string, CCharacterData> heroesTemplate = CTaskUtil.Get(CTaskUtil.HERO_TEMPLATES) as Dictionary <string, CCharacterData>;

            if (isHeroTemplate)
            {
                var heroTemplateJson = receiveData.GetField("heroesTemplate").ToString();
                heroesTemplate = TinyJSON.JSON.Load(heroTemplateJson).Make <Dictionary <string, CCharacterData> > ();
            }
            CTaskUtil.Set(CTaskUtil.HERO_TEMPLATES, heroesTemplate);
        }