Exemple #1
0
    public void AddCharacter(CharacterInfo character)
    {
        var placeholder = new GameObject("CharacterPlaceHolder" + _characters.Count);

        placeholder.transform.SetParent(transform, false);
        _characters.Add(placeholder);

        _assetManager.LoadAssetByNameAsync(character.Id,
                                           go =>
        {
            var index = _characters.IndexOf(placeholder);
            Destroy(placeholder);

            go.transform.SetParent(transform, false);
            go.transform.localPosition = offset * index;
            _characters[index]         = go;

            var data = go.GetComponent <CharactersBindData>();
            data.SetSkinType(character.SkinType);
            data.SetHealthBarType(CharactersBindData.HealthBarType.None);
        });
    }
Exemple #2
0
        private void StartLocalBattle(HashSet <string> skillId, HashSet <string> attackSkillIds, RemoteConfig.CharacterInfo character)
        {
            var mainSkill = _appConfig.GetSkillConfigById(skillId.First());
            List <SkillInfo> skillInfos = new List <SkillInfo>()
            {
                mainSkill
            };

            foreach (var skill  in attackSkillIds)
            {
                var skillInfo = _appConfig.GetSkillConfigById(skill);
                skillInfos.Add(skillInfo);
            }

            Container.Register(new Session {
                MainSkill    = mainSkill,
                AttackSkill  = skillInfos[1],
                DefenceSkill = skillInfos[2],
                UtilitySkill = skillInfos[3],
                Character    = character
            });

            uiController.MainUI.Hide();
            uiController.LoadingUI.Show();

            //TODO: need to find way for make it better
            Observable.Timer(TimeSpan.FromSeconds(1))
            .Subscribe(
                (x) => { },
                () => {
                Container.Resolve <InputMaster>().Enable();
                uiController.LoadingUI.Hide();
                uiController.GameUI.Show(skillInfos.Take(4).ToArray());
            })
            .AddTo(this);

            InitWorlds(useLocalServer ? "127.0.0.1" : _appConfig.Main.ServerAddress, useLocalServer ? (ushort)7979 : _appConfig.Main.ServerPort);
        }