示例#1
0
    private void CreateSpine(EntityVo entity, int spineIndex, int childIndex)
    {
        GameObject go = null;

        if (_spineCache.Count < spineIndex)
        {
            go = InstantiatePrefab("Spine/SpineSkeletonGraphic");
            SkeletonGraphic skeletonGraphic = go.GetComponent <SkeletonGraphic>();
            _spineCache.Add(skeletonGraphic);
        }
        else
        {
            go = _spineCache[spineIndex - 1].gameObject;
        }

        SpineHeadAnimation sha = go.GetComponent <SpineHeadAnimation>();

        sha.LoadAnimation(entity.id, entity.playableList);

        go.transform.SetParent(transform, false);

        RectTransform rt = go.GetComponent <RectTransform>();

        rt.pivot            = new Vector2(0.5f, 0);
        rt.sizeDelta        = new Vector2(entity.width, entity.height);
        rt.anchoredPosition = new Vector2(entity.x, entity.y - _offsetY);

        rt.SetSiblingIndex(childIndex);
    }
示例#2
0
        private static string GetResId(EntityVo vo)
        {
            if (vo == null)
            {
                return(null);
            }
            string npc_id = vo.npc_id;

            if (npc_id != string.Empty)
            {
                if (vo.entity_type == EntityType.Hero)
                {
                    SysHeroMainVo heroMainData = BaseDataMgr.instance.GetHeroMainData(npc_id);
                    if (heroMainData == null)
                    {
                    }
                    return(heroMainData.model_id);
                }
                if (vo.entity_type == EntityType.Monster)
                {
                    SysMonsterMainVo monsterMainData = BaseDataMgr.instance.GetMonsterMainData(npc_id);
                    return(monsterMainData.model_id);
                }
                ClientLogger.Error("cannot support " + vo.entity_type);
            }
            return(null);
        }
示例#3
0
 public static EntityVo GetEntityVo(string npc_config, EntityType type, TeamType team, Func <string, EntityType, TeamType, string> modelIdModifier = null)
 {
     if (npc_config != null && npc_config != "[]" && npc_config != string.Empty)
     {
         string[] stringValue = StringUtils.GetStringValue(npc_config, '|');
         EntityVo result;
         if (type == EntityType.Hero)
         {
             string npc_id  = stringValue[0];
             int    ai_type = int.Parse(stringValue[1]);
             int    level   = int.Parse(stringValue[2]);
             int    star    = int.Parse(stringValue[3]);
             int    quality = int.Parse(stringValue[4]);
             result = new EntityVo(type, npc_id, level, star, quality, 0f, 0f, ai_type, 0);
         }
         else
         {
             string text     = stringValue[0];
             int    ai_type2 = int.Parse(stringValue[1]);
             int    pos      = int.Parse(stringValue[2]);
             if (modelIdModifier != null)
             {
                 text = modelIdModifier(text, type, team);
             }
             result = new EntityVo(type, text, pos, ai_type2, string.Empty, "Default", 0);
         }
         return(result);
     }
     return(null);
 }
示例#4
0
        public void SetData(EntityVo vo)
        {
            if (_live2dCanvas.Live2dCamera.targetTexture != null)
            {
                Debug.LogError("===========_live2dCanvas.Live2dCamera.targetTexture==============");
            }

            var w      = vo.width;
            var h      = vo.height;
            var target = new RenderTexture((int)w, (int)h, (int)Screen.dpi, RenderTextureFormat.ARGB32);

            _live2dCanvas.Live2dCamera.targetTexture = target;

            _image         = transform.GetComponent <RawImage>();
            _image.texture = _live2dCanvas.Live2dCamera.targetTexture;

            _entityVo = vo;
            if (_live2dView == null)
            {
                _live2dView = Live2dManager.CreateL2DView(vo.id, _live2dCanvas, _donotUnloadIds);
                //  _live2dView.Live2dViewType = LIVE2DVIEWTYPE.MAINPANLE;
            }
            else
            {
                _live2dView.LoadModel(vo.id, _donotUnloadIds);
            }

            _live2dView.X     = vo.L2dScaleDataList[0];
            _live2dView.Y     = vo.L2dScaleDataList[1];
            _live2dView.Width = vo.L2dScaleDataList[2];

            _live2dView.LipSync = vo.lipSpync;
        }
        public static Units CreateEyeItemByUnitInfo(UnitInfo info)
        {
            if (!StringUtils.CheckValid(info.burnValue))
            {
                ClientLogger.Error(string.Concat(new object[]
                {
                    "burnValue is invalid, use default position #",
                    info.typeId,
                    "  utype:",
                    info.unitType
                }));
                return(null);
            }
            string[] stringValue = StringUtils.GetStringValue(info.burnValue, '|');
            if (stringValue.Length != 6)
            {
                ClientLogger.Error("eye item burnValue is stuctured wrong");
                return(null);
            }
            int num = -1;

            if (!int.TryParse(stringValue[2], out num))
            {
                ClientLogger.Error("parse eye item pos failed");
                return(null);
            }
            if (num < 0)
            {
                ClientLogger.Error("eye item pos invalid");
                return(null);
            }
            Transform spawnPos = MapManager.Instance.GetSpawnPos(TeamType.Neutral, num);
            TeamType  teamType = PvpProtocolTools.GroupToTeam((int)info.group);
            EntityVo  npcinfo  = new EntityVo(EntityType.Monster, info.typeId, num, 9, string.Empty, "Default", 0)
            {
                uid = info.unitId
            };
            SpawnUtility spawnUtility = GameManager.Instance.Spawner.GetSpawnUtility();
            Units        units        = spawnUtility.SpawnEyeItemInstance(npcinfo, "Monster", teamType, "[]", spawnPos, info.position, stringValue[4], UnitControlType.None);

            if (units == null)
            {
                ClientLogger.Error("P2C_CreateUnits create monster failed, " + StringUtils.DumpObject(info));
                return(null);
            }
            units.SetOrigin(true, info.creepId.ToString(), info.monsterTeamId);
            units.TryAddBirthEffect();
            units.SetIsMonsterCreep(false);
            PvpProtocolTools.SyncUnitLifeStateAndSkill(units, info, 0L);
            if (units.isMonster && units.skillManager != null)
            {
                units.skillManager.EnableSkills(true);
            }
            return(units);
        }
示例#6
0
 private void OnHeroSpawned(Units hero, EntityVo entityVo)
 {
     if (hero != null)
     {
         VTrigger item = TriggerManager.CreateUnitEventTrigger(UnitEvent.UnitDeath, null, new TriggerAction(this.RespawnHero), hero.unique_id);
         this._respawnTriggers.Add(item);
     }
     if (this._onSpawnAction != null)
     {
         this._onSpawnAction(hero, entityVo);
     }
 }
示例#7
0
        public EntityVo GetEntityVo(string npcConfig, EntityType type, TeamType team, int uniqId = 0)
        {
            if (npcConfig == null || npcConfig == "[]" || npcConfig == string.Empty)
            {
                return(null);
            }
            string[] stringValue = StringUtils.GetStringValue(npcConfig, '|');
            EntityVo result;

            if (type == EntityType.Hero)
            {
                string npc_id  = stringValue[0];
                int    ai_type = int.Parse(stringValue[1]);
                int    level   = int.Parse(stringValue[2]);
                int    star    = int.Parse(stringValue[3]);
                int    quality = int.Parse(stringValue[4]);
                result = new EntityVo(type, npc_id, level, star, quality, 0f, 0f, ai_type, 0)
                {
                    uid = uniqId
                };
            }
            else
            {
                string oldId    = stringValue[0];
                int    ai_type2 = int.Parse(stringValue[1]);
                int    pos      = int.Parse(stringValue[2]);
                string npc_id2  = this._mapper(oldId, type, team);
                if (type == EntityType.Tower || type == EntityType.Home)
                {
                    string priority = string.Empty;
                    if (stringValue.Length == 4)
                    {
                        priority = stringValue[3];
                    }
                    result = new EntityVo(type, npc_id2, pos, ai_type2, priority, "Default", 0)
                    {
                        uid = uniqId
                    };
                }
                else
                {
                    result = new EntityVo(type, npc_id2, pos, ai_type2, string.Empty, "Default", 0)
                    {
                        uid = uniqId
                    };
                }
            }
            return(result);
        }
    public static List <EntityVo> ConvertFromHeroInfo(List <HeroInfoData> infos)
    {
        List <EntityVo> list = new List <EntityVo>();

        if (infos != null)
        {
            for (int i = 0; i < infos.Count; i++)
            {
                HeroInfoData heroInfoData = infos[i];
                EntityVo     item         = new EntityVo(EntityType.Hero, heroInfoData.ModelId, CharacterDataMgr.instance.GetLevel(heroInfoData.Exp), heroInfoData.Level, heroInfoData.Grade, 0f, 0f, 0, 0);
                list.Add(item);
            }
        }
        return(list);
    }
示例#9
0
        private List <EntityVo> GetHeroes(TeamType team)
        {
            List <EntityVo> list = new List <EntityVo>();

            foreach (ReadyPlayerSampleInfo current in this._roomInfo.PvpPlayers)
            {
                if (current.GetTeam() == team)
                {
                    EntityVo vo = PvpManager.GetVo(current);
                    vo.uid = -current.newUid;
                    list.Add(vo);
                }
            }
            return(list);
        }
    public static EntityVo GetMyHero(string heroId)
    {
        HeroInfoData heroInfoData = ModelManager.Instance.Get_heroInfo_item_byModelID_X(heroId);
        EntityVo     result;

        if (heroInfoData != null)
        {
            result = new EntityVo(EntityType.Hero, heroId, CharacterDataMgr.instance.GetLevel(heroInfoData.Exp), heroInfoData.Level, heroInfoData.Grade, 0f, 0f, 0, 0);
        }
        else
        {
            result = new EntityVo(EntityType.Hero, heroId, 1, 1, 1, 0f, 0f, 0, 0);
        }
        return(result);
    }
示例#11
0
        public List <EntityVo> GetPvpEntityVos(string npcConfig, EntityType type, TeamType team, int startUniqId)
        {
            if (npcConfig == null || npcConfig == "[]" || npcConfig == string.Empty)
            {
                return(null);
            }
            List <EntityVo> list = new List <EntityVo>();

            string[] stringValue = StringUtils.GetStringValue(npcConfig, ',');
            for (int i = 0; i < stringValue.Length; i++)
            {
                EntityVo entityVo = this.GetEntityVo(stringValue[i], type, team, startUniqId++);
                list.Add(entityVo);
            }
            return(list);
        }
示例#12
0
        public Units SpawnEyeItemInstance(EntityVo npcinfo, string tag, TeamType teamType, string respawnInterval, Transform newSpawnPoint, SVector3 eyeItemInfoInst, string eyeItemPreObjRes, UnitControlType controlType)
        {
            if (npcinfo == null || npcinfo.npc_id == null || npcinfo.npc_id == string.Empty || tag == null)
            {
                return(null);
            }
            string           npc_id          = npcinfo.npc_id;
            SysMonsterMainVo monsterMainData = BaseDataMgr.instance.GetMonsterMainData(npc_id);

            if (monsterMainData == null)
            {
                ClientLogger.Error("SpawnInstance: no npc found #" + npc_id);
                return(null);
            }
            Dictionary <DataType, object> dictionary = new Dictionary <DataType, object>
            {
                {
                    DataType.NameId,
                    npc_id
                },
                {
                    DataType.ModelId,
                    monsterMainData.model_id
                },
                {
                    DataType.TeamType,
                    teamType
                },
                {
                    DataType.AIType,
                    npcinfo.ai_type
                },
                {
                    DataType.AttrFactor,
                    SpawnUtility.GetAttrFactor(teamType, this._myScene)
                }
            };

            if (npcinfo.uid != 0)
            {
                dictionary.Add(DataType.UniqueId, npcinfo.uid);
            }
            Dictionary <AttrType, float> unitAttrs = new Dictionary <AttrType, float>();

            return(MapManager.Instance.SpawnEyeItemUnit(tag, dictionary, unitAttrs, newSpawnPoint, eyeItemInfoInst, eyeItemPreObjRes, controlType, false));
        }
示例#13
0
 private void OnTowerSpawned(Units units, EntityVo entityVo)
 {
     if (units != null && (units.tag.Equals("Building") || units.tag.Equals("Home")))
     {
         Tower tower = units as Tower;
         if (tower != null)
         {
             if (StringUtils.CheckValid(entityVo.atk_priority))
             {
                 tower.TowerPriority = int.Parse(entityVo.atk_priority);
             }
             tower.Prewarm();
         }
     }
     if (this._onSpawnAction != null)
     {
         this._onSpawnAction(units, entityVo);
     }
 }
示例#14
0
        private void SpawnTowers()
        {
            if (this.MyScene.guard_id != "[]")
            {
                string[] stringValue = StringUtils.GetStringValue(this.MyScene.guard_id, ',');
                EntityVo entityVo    = this._entityVoCreator.GetEntityVo(stringValue[0], EntityType.Home, TeamType.LM, 1);
                Units    units       = this.SpawnUtility.SpawnInstance(entityVo, "Home", TeamType.LM, 0, "[]", null, UnitControlType.None, UnitType.None);
                this.OnTowerSpawned(units, entityVo);
                if (stringValue.Length > 1)
                {
                    EntityVo entityVo2 = this._entityVoCreator.GetEntityVo(stringValue[1], EntityType.Home, TeamType.BL, 51);
                    Units    units2    = this.SpawnUtility.SpawnInstance(entityVo2, "Home", TeamType.BL, 0, "[]", null, UnitControlType.None, UnitType.None);
                    this.OnTowerSpawned(units2, entityVo2);
                }
            }
            IEnumerator enumerator = null;

            if (this.MyScene.tower_1 != "[]")
            {
                enumerator = base.SpawnInstances_Coroutinue(this._entityVoCreator.GetPvpEntityVos(this.MyScene.tower_1, EntityType.Tower, TeamType.LM, 2), "Building", TeamType.LM, string.Empty, 0f, 0f, "[]", null, new BaseSpawnTask.OnSpawnUnit(this.OnTowerSpawned));
            }
            IEnumerator enumerator2 = null;

            if (this.MyScene.tower_2 != "[]")
            {
                enumerator2 = base.SpawnInstances_Coroutinue(this._entityVoCreator.GetPvpEntityVos(this.MyScene.tower_2, EntityType.Tower, TeamType.BL, 52), "Building", TeamType.BL, string.Empty, 0f, 0f, "[]", null, new BaseSpawnTask.OnSpawnUnit(this.OnTowerSpawned));
            }
            IEnumerator enumerator3 = null;

            if (!string.IsNullOrEmpty(this.MyScene.tower_3) && this.MyScene.tower_3 != "[]")
            {
                enumerator3 = base.SpawnInstances_Coroutinue(this._entityVoCreator.GetPvpEntityVos(this.MyScene.tower_3, EntityType.Tower, TeamType.Team_3, 102), "Building", TeamType.Team_3, string.Empty, 0f, 0f, "[]", null, new BaseSpawnTask.OnSpawnUnit(this.OnTowerSpawned));
            }
            this.MyCoroutineManager.StartCoroutine(BaseSpawnTask.ConcatEnum(new IEnumerator[]
            {
                enumerator,
                enumerator2,
                enumerator3,
                base.TriggerFinishEvents(true)
            }), true);
        }
示例#15
0
    public void SetGroupItems(EntityVo[] ovList, ref List <HeadItem> list)
    {
        int count = list.Count;

        for (int i = 0; i < count; i++)
        {
            HeadItem headItem = list[i];
            if (i >= ovList.Length || ovList.Length <= 0)
            {
                headItem.gameObject.SetActive(false);
            }
            else
            {
                headItem.gameObject.SetActive(true);
                EntityVo      entityVo     = ovList[i];
                SysHeroMainVo heroMainData = BaseDataMgr.instance.GetHeroMainData(entityVo.npc_id);
                headItem.UpdateItemById(entityVo.uid, heroMainData.avatar_icon, heroMainData.npc_id);
                this.m_activeItems.Add(headItem);
            }
        }
    }
示例#16
0
    private void CreateLive2D(EntityVo entity, int live2DIndex, int childIndex)
    {
        GameObject    go = null;
        Live2dGraphic live2DGraphic;

        if (_live2DCache.Count < live2DIndex)
        {
            go            = InstantiatePrefab(L2DConst.Live2dGraphicPath);
            live2DGraphic = go.GetComponent <Live2dGraphic>();
            _live2DCache.Add(live2DGraphic);
        }
        else
        {
            go            = _live2DCache[live2DIndex - 1].gameObject;
            live2DGraphic = go.GetComponent <Live2dGraphic>();
            live2DGraphic.Show();
        }

        if (live2DGraphic.GetMainLive2DView != null && live2DGraphic.GetMainLive2DView.ModelId == entity.id)
        {
            live2DGraphic.ChangeAnimation(entity);
        }
        else
        {
            live2DGraphic.SetData(entity);
            live2DGraphic.Play();
        }

        go.transform.SetParent(transform, false);

        RectTransform rt = go.GetComponent <RectTransform>();

        rt.pivot            = new Vector2(0.5f, 0.5f);
        rt.sizeDelta        = new Vector2(entity.width, entity.height);
        rt.anchoredPosition = new Vector2(entity.x, entity.y - _offsetY);

        rt.SetSiblingIndex(childIndex);
    }
示例#17
0
    public void InsertEntitySkillData(EntityVo entityVo)
    {
        EntityType entity_type = entityVo.entity_type;

        if (entity_type == EntityType.Hero)
        {
            int           skin         = (entityVo.skin <= 0) ? 0 : entityVo.skin;
            SysHeroMainVo heroMainData = BaseDataMgr.instance.GetHeroMainData(entityVo.npc_id);
            if (heroMainData != null)
            {
                string[] stringValue = StringUtils.GetStringValue(heroMainData.attack_id, ',');
                if (!ArrayTool.isNullOrEmpty(stringValue))
                {
                    string[] array = stringValue;
                    for (int i = 0; i < array.Length; i++)
                    {
                        string skillID = array[i];
                        this.InsertData(skillID, skin);
                    }
                }
                string[] stringValue2 = StringUtils.GetStringValue(heroMainData.skill_id, ',');
                if (!ArrayTool.isNullOrEmpty(stringValue2))
                {
                    string[] array2 = stringValue2;
                    for (int j = 0; j < array2.Length; j++)
                    {
                        string skillID2 = array2[j];
                        this.InsertData(skillID2, skin);
                    }
                }
            }
            else
            {
                Debug.LogError("Hero [" + entityVo.npc_id + "] is wrong!!");
            }
        }
    }
        public static Units CreateHeroByUnitInfo(UnitInfo info)
        {
            Units result;

            try
            {
                if (info == null)
                {
                    result = null;
                }
                else
                {
                    EntityVo entityVo = new EntityVo(EntityType.Hero, info.typeId, 0, 0, string.Empty, "Default", 0)
                    {
                        uid      = info.unitId,
                        level    = info.level,
                        hp       = 99999f,
                        mp       = 99999f,
                        effectId = string.Empty
                    };
                    Units unit = MapManager.Instance.GetUnit(info.mainHeroId);
                    if (unit != null)
                    {
                        if (unit.npc_id == "Jiansheng")
                        {
                            entityVo.effectId = "1|Perform_jsbirth_fenshen";
                        }
                        else if (unit.npc_id == "Houzi")
                        {
                        }
                    }
                    SpawnUtility spawnUtility = GameManager.Instance.Spawner.GetSpawnUtility();
                    Vector3      vector       = MoveController.SVectgor3ToVector3(info.position);
                    string       userName     = (!(unit == null)) ? unit.summonerName : "1";
                    string       summerId     = "1";
                    Units        units        = spawnUtility.SpawnPvpHero(entityVo, "Hero", (TeamType)info.group, 0, userName, summerId, new Vector3?(vector), UnitType.FenShenHero);
                    if (units != null && unit != null)
                    {
                        units.level = unit.level;
                        units.data.SetMaxHp(unit.hp_max);
                        units.data.SetMaxMp(unit.mp_max);
                        units.data.SetHp(unit.hp);
                        units.data.SetMp(unit.mp);
                        units.SetParentUnit(unit);
                        units.SetMirrorState(true);
                        if (unit.npc_id == "Jiansheng")
                        {
                            units.SetCanAIControl(true);
                            units.SetCanSkill(false);
                            units.effect_id = "2|Perform_jsdead_fenshen";
                        }
                        else if (unit.npc_id == "Houzi")
                        {
                            units.effect_id = "2|FenShenDeath,2|DashengS2";
                            units.SetCanAIControl(false);
                            units.SetCanAction(false);
                            units.trans.rotation = unit.trans.rotation;
                        }
                        Units selectedTarget = PlayerControlMgr.Instance.GetSelectedTarget();
                        if (selectedTarget != null && unit.unique_id == selectedTarget.unique_id)
                        {
                            PlayerControlMgr.Instance.GetPlayer().SetSelectTarget(null);
                            PlayerControlMgr.Instance.GetPlayer().SetAttackTarget(null);
                            PlayerControlMgr.Instance.SetSelectedTarget(null);
                        }
                        units.SetPosition(vector, true);
                    }
                    result = units;
                }
            }
            catch (Exception e)
            {
                ClientLogger.LogException(e);
                result = null;
            }
            return(result);
        }
示例#19
0
    private void ShowPageStep2()
    {
        if (_lastBgId != null && _lastBgId != _currentDialogVo.BgImageId)
        {
            AssetManager.Instance.UnloadBundle(AssetLoader.GetStoryBgImage(_lastBgId));
            _storyLoader.BgImageCache.Remove(_lastBgId);
        }

        if (!string.IsNullOrEmpty(_currentDialogVo.BgMusicId) && _lastBgMusicId != _currentDialogVo.BgMusicId)
        {
            _lastBgMusicId = _currentDialogVo.BgMusicId;

            if (_lastBgMusicId.IndexOf("${mute}", StringComparison.Ordinal) != -1)
            {
                AudioManager.Instance.StopBackgroundMusic();
            }
            else
            {
                AudioManager.Instance.TweenVolumTo(AudioManager.Instance.BgMusicVolum, 2.5f);
                new AssetLoader().LoadAudio(AssetLoader.GetBackgrounMusicById(_lastBgMusicId),
                                            (clip, loader) => { AudioManager.Instance.PlayBackgroundMusic(clip); });
            }
        }

        if (!string.IsNullOrEmpty(_currentDialogVo.DubbingId))
        {
            AudioManager.Instance.TweenVolumTo(0.33f, 0);
            new AssetLoader().LoadAudio(AssetLoader.GetDubbingById(_currentDialogVo.DubbingId),
                                        (clip, loader) =>
            {
                if (clip == null)
                {
                    Debug.LogWarning("AssetLoader Error->" + loader.FilePath);
                    return;
                }
                ClientTimer.Instance.DelayCall(() =>
                {
                    _dialogFrame.SetAudioTime(clip.length);
                    AudioManager.Instance.PlayDubbing(clip);
                }, 0.5f);
            });
        }
        else
        {
            AudioManager.Instance.StopDubbing();
            AudioManager.Instance.TweenVolumTo(1f, 2.5f);
        }

        _lastBgMusicId = _currentDialogVo.BgMusicId;

        if (_lastBgId != _currentDialogVo.BgImageId)
        {
            _lastBgId        = _currentDialogVo.BgImageId;
            _bgImage.texture = _storyLoader.BgImageCache[_currentDialogVo.BgImageId];

            _bgImage.GetComponent <RectTransform>().sizeDelta =
                new Vector2(_currentDialogVo.Width, _currentDialogVo.Height);
            BackgroundSizeFitter fitter = _bgImage.GetComponent <BackgroundSizeFitter>();
            if (_currentDialogVo.Width > 1080)
            {
                fitter.FitType = FitType.Heigth;
            }
            else
            {
                fitter.FitType = FitType.Background;
            }

            fitter.Reset();
            fitter.DoFit();
        }

        _bgImage.color = Color.white;

        bool hasDialog = false;

        int roleIndex   = 0;
        int spineIndex  = 0;
        int live2dIndex = 0;

        _role1.gameObject.SetActive(false);
        _role2.gameObject.SetActive(false);

        int childIndex = 0;

        if (_currentDialogVo.EntityList.Count > 0)
        {
            for (int i = 0; i < _currentDialogVo.EntityList.Count; i++)
            {
                EntityVo      entity = _currentDialogVo.EntityList[i];
                RectTransform rt     = null;
                if (entity.type == EntityVo.EntityType.Role)
                {
                    roleIndex++;
                    childIndex++;
                    bool resetSprite = true;

                    if (roleIndex == 1)
                    {
                        if (_lastRoleId1 == entity.id)
                        {
                            resetSprite = false;
                        }

                        rt           = _role1.GetComponent <RectTransform>();
                        _lastRoleId1 = entity.id;
                    }
                    else
                    {
                        if (_lastRoleId2 == entity.id)
                        {
                            resetSprite = false;
                        }

                        rt           = _role2.GetComponent <RectTransform>();
                        _lastRoleId2 = entity.id;
                    }

                    RawImage img = rt.GetComponent <RawImage>();
                    if (resetSprite)
                    {
                        img.texture = _storyLoader.RoleImageCache[entity.id];
                    }

                    img.color = new Color(entity.color, entity.color, entity.color);

                    rt.gameObject.SetActive(true);
                    rt.anchoredPosition = new Vector3(entity.x, entity.y - _offsetY);
                    rt.sizeDelta        = new Vector2(entity.width, entity.height);

                    rt.SetSiblingIndex(childIndex);
                }
                else if (entity.type == EntityVo.EntityType.DialogFrame)
                {
                    hasDialog = true;

                    rt = _dialogFrame.GetComponent <RectTransform>();
                    rt.localPosition = new Vector3(0, -240 - _offsetY, 0);
                    rt.sizeDelta     = new Vector2(entity.width, entity.height);

                    float delayTime = _isDelayDialog ? 1.3f : 0.38f;
                    _dialogFrame.SetData(entity);
                    _dialogFrame.Show(delayTime);

                    SendMessage(new Message(MessageConst.CMD_STORY_RECODE_DIALOG, Message.MessageReciverType.DEFAULT, entity, entity.roleName));

                    if (!string.IsNullOrEmpty(entity.headId))
                    {
                        _dialogFrame.SetHeadTexture(_storyLoader.HeadImageCache[entity.headId]);
                    }
                }
                else if (entity.type == EntityVo.EntityType.Spine)
                {
                    spineIndex++;
                    CreateSpine(entity, spineIndex, ++childIndex);
                }
                else if (entity.type == EntityVo.EntityType.Live2D)
                {
                    live2dIndex++;
                    CreateLive2D(entity, live2dIndex, ++childIndex);
                }
            }
        }

        //3个跳转选项
        if (_currentIndex >= _dialogList.Count - 1 &&
            _currentDialogVo.Event != null &&
            _currentDialogVo.Event.EventType == EventType.Selection)
        {
            CreateSelection(_currentDialogVo.Event);
        }


        for (int i = _spineCache.Count - 1; i >= 0; i--)
        {
            if (i >= spineIndex)
            {
                SkeletonGraphic skg = _spineCache[i];
                DestroyImmediate(skg);
                _spineCache.RemoveAt(i);
            }
        }

        for (int i = _live2DCache.Count - 1; i >= 0; i--)
        {
            if (i >= live2dIndex)
            {
                Live2dGraphic l2g = _live2DCache[i];
                l2g.Hide();
            }
        }

        if (_isDelayDialog)
        {
            _dialogFrame.gameObject.SetActive(false);
            _isDelayDialog = false;
        }

        if (hasDialog == false)
        {
            ClientTimer.Instance.DelayCall(DoAutoPlay, 1.2f);
            _dialogFrame.gameObject.SetActive(false);
        }
    }
示例#20
0
        public Units SpawnInstance(EntityVo npcinfo, string tag, TeamType teamType, int spawnPos, string respawnInterval = "[]", Transform newSpawnPoint = null, UnitControlType controlType = UnitControlType.None, UnitType unitType = UnitType.None)
        {
            if (npcinfo == null || npcinfo.npc_id == null || npcinfo.npc_id == string.Empty || tag == null)
            {
                ClientLogger.Error("SpawnInstance line 1 null");
                return(null);
            }
            Dictionary <AttrType, float> dictionary = new Dictionary <AttrType, float>();

            if (tag == "Hero" || tag == "Player")
            {
                string        npc_id       = npcinfo.npc_id;
                int           level        = npcinfo.level;
                int           quality      = npcinfo.quality;
                int           star         = npcinfo.star;
                float         hp           = npcinfo.hp;
                float         mp           = npcinfo.mp;
                SysHeroMainVo heroMainData = BaseDataMgr.instance.GetHeroMainData(npc_id);
                if (heroMainData == null || heroMainData.model_id == null)
                {
                    ClientLogger.Error("SpawnInstance: no hero found #" + npc_id);
                    return(null);
                }
                Dictionary <DataType, object> dictionary2 = new Dictionary <DataType, object>
                {
                    {
                        DataType.NameId,
                        npc_id
                    },
                    {
                        DataType.ModelId,
                        heroMainData.model_id
                    },
                    {
                        DataType.TeamType,
                        teamType
                    },
                    {
                        DataType.AIType,
                        2
                    },
                    {
                        DataType.AttrFactor,
                        SpawnUtility.GetAttrFactor(teamType, this._myScene)
                    },
                    {
                        DataType.Level,
                        level
                    },
                    {
                        DataType.Quality,
                        quality
                    },
                    {
                        DataType.Star,
                        star
                    },
                    {
                        DataType.Skin,
                        npcinfo.skin
                    }
                };
                if (npcinfo.uid != 0)
                {
                    dictionary2.Add(DataType.UniqueId, npcinfo.uid);
                }
                if (hp != 0f)
                {
                    dictionary.Add(AttrType.Hp, hp);
                }
                if (mp != 0f)
                {
                    dictionary.Add(AttrType.Mp, mp);
                }
                Transform transform = newSpawnPoint;
                if (!transform)
                {
                    transform = MapManager.Instance.GetSpawnPos(teamType, spawnPos);
                }
                Units result = MapManager.Instance.SpawnUnit(tag, dictionary2, dictionary, transform.position, transform.rotation, controlType, true, null, unitType);
                if (!transform)
                {
                    ClientLogger.Error(string.Format("SpawnInstance: GetSpawnPos failed for {0} {1} in {2}", teamType, spawnPos, LevelManager.CurLevelId));
                }
                return(result);
            }
            else if (tag.Equals("Home"))
            {
                string    npc_id2    = npcinfo.npc_id;
                Transform transform2 = newSpawnPoint;
                if (!transform2)
                {
                    transform2 = MapManager.Instance.GetSpawnPos(teamType, npcinfo.pos);
                }
                SysMonsterMainVo monsterMainData = BaseDataMgr.instance.GetMonsterMainData(npc_id2);
                if (monsterMainData == null)
                {
                    ClientLogger.Error("SpawnInstance: no home found #" + npc_id2);
                    return(null);
                }
                Dictionary <DataType, object> dictionary3 = new Dictionary <DataType, object>
                {
                    {
                        DataType.NameId,
                        npc_id2
                    },
                    {
                        DataType.ModelId,
                        monsterMainData.model_id
                    },
                    {
                        DataType.TeamType,
                        teamType
                    },
                    {
                        DataType.AIType,
                        npcinfo.ai_type
                    },
                    {
                        DataType.AttrFactor,
                        SpawnUtility.GetAttrFactor(teamType, this._myScene)
                    },
                    {
                        DataType.Skin,
                        npcinfo.skin
                    }
                };
                if (npcinfo.uid != 0)
                {
                    dictionary3.Add(DataType.UniqueId, npcinfo.uid);
                }
                return(MapManager.Instance.SpawnUnit(tag, dictionary3, dictionary, transform2.position, transform2.rotation, controlType, false, null, unitType));
            }
            else
            {
                string    npc_id3    = npcinfo.npc_id;
                Transform transform3 = newSpawnPoint;
                if (!transform3)
                {
                    transform3 = MapManager.Instance.GetSpawnPos(teamType, npcinfo.pos);
                }
                SysMonsterMainVo monsterMainData2 = BaseDataMgr.instance.GetMonsterMainData(npc_id3);
                if (monsterMainData2 == null)
                {
                    ClientLogger.Error("SpawnInstance: no npc found #" + npc_id3);
                    return(null);
                }
                Dictionary <DataType, object> dictionary4 = new Dictionary <DataType, object>
                {
                    {
                        DataType.NameId,
                        npc_id3
                    },
                    {
                        DataType.ModelId,
                        monsterMainData2.model_id
                    },
                    {
                        DataType.TeamType,
                        teamType
                    },
                    {
                        DataType.AIType,
                        npcinfo.ai_type
                    },
                    {
                        DataType.AttrFactor,
                        SpawnUtility.GetAttrFactor(teamType, this._myScene)
                    },
                    {
                        DataType.Skin,
                        npcinfo.skin
                    }
                };
                if (npcinfo.uid != 0)
                {
                    dictionary4.Add(DataType.UniqueId, npcinfo.uid);
                }
                return(MapManager.Instance.SpawnUnit(tag, dictionary4, dictionary, transform3.position, transform3.rotation, controlType, false, null, unitType));
            }
        }
示例#21
0
        public Units SpawnPvpHero(EntityVo npcinfo, string tag, TeamType teamType, int spawnPos, string userName = "", string summerId = "", Vector3?specifyPos = null, UnitType unitType = UnitType.None)
        {
            if (npcinfo == null || npcinfo.npc_id == string.Empty)
            {
                return(null);
            }
            if (tag != "Hero" && tag != "Player")
            {
                return(null);
            }
            string npc_id = npcinfo.npc_id;
            Dictionary <DataType, object> dictionary = new Dictionary <DataType, object>();
            int           num          = 2;
            int           level        = npcinfo.level;
            int           quality      = npcinfo.quality;
            int           star         = npcinfo.star;
            float         hp           = npcinfo.hp;
            float         mp           = npcinfo.mp;
            SysHeroMainVo heroMainData = BaseDataMgr.instance.GetHeroMainData(npc_id);

            dictionary.Add(DataType.NameId, npc_id);
            dictionary.Add(DataType.ModelId, heroMainData.model_id);
            dictionary.Add(DataType.TeamType, teamType);
            dictionary.Add(DataType.AIType, num);
            dictionary.Add(DataType.AttrFactor, this.GetAttrFactor(teamType));
            dictionary.Add(DataType.Level, level);
            dictionary.Add(DataType.Quality, quality);
            dictionary.Add(DataType.Star, star);
            if (npcinfo.uid != 0)
            {
                dictionary.Add(DataType.UniqueId, npcinfo.uid);
            }
            if (npcinfo.effectId != "Default")
            {
                dictionary.Add(DataType.EffectId, npcinfo.effectId);
            }
            Dictionary <AttrType, float> dictionary2 = new Dictionary <AttrType, float>();

            if (hp != 0f)
            {
                dictionary2.Add(AttrType.Hp, hp);
            }
            if (mp != 0f)
            {
                dictionary2.Add(AttrType.Mp, mp);
            }
            bool reuse = false;

            if (LevelManager.Instance.IsPvpBattleType)
            {
                reuse = true;
                if (userName == string.Empty)
                {
                    dictionary.Add(DataType.summerName, Singleton <PvpManager> .Instance.PvpPlayers.FirstOrDefault((ReadyPlayerSampleInfo obj) => obj.newUid.ToString() == Math.Abs(npcinfo.uid).ToString()).userName);
                }
                else
                {
                    dictionary.Add(DataType.summerName, userName);
                }
                if (summerId == string.Empty)
                {
                    dictionary.Add(DataType.summerId, Singleton <PvpManager> .Instance.PvpPlayers.FirstOrDefault((ReadyPlayerSampleInfo obj) => obj.newUid.ToString() == Math.Abs(npcinfo.uid).ToString()).SummerId);
                }
                else
                {
                    dictionary.Add(DataType.summerId, summerId);
                }
            }
            else if (LevelManager.Instance.IsServerZyBattleType)
            {
                reuse = true;
            }
            Vector3 position = Vector3.zero;

            if (!specifyPos.HasValue)
            {
                position = MapManager.Instance.GetSpawnPos(teamType, spawnPos).position;
            }
            else
            {
                position = specifyPos.Value;
            }
            return(MapManager.Instance.SpawnUnit(tag, dictionary, dictionary2, position, Quaternion.identity, UnitControlType.None, reuse, null, unitType));
        }
示例#22
0
 /// <summary>
 /// 在live2dId相同的情况下才能使用
 /// </summary>
 /// <param name="vo"></param>
 public void ChangeAnimation(EntityVo vo)
 {
     _entityVo = vo;
     _sequence.ChangeAnimation(vo.l2dPlayableList);
     _live2dView.LipSync = vo.lipSpync;
 }
        public static Units CreateMonsterByUnitInfo(UnitInfo info)
        {
            Units result;

            try
            {
                if (info == null)
                {
                    ClientLogger.Error("CreateMonsterByUnitInfo: info is null");
                    result = null;
                }
                else if (MapManager.Instance == null)
                {
                    ClientLogger.Error("MapManager.Instance is null");
                    result = null;
                }
                else if (GlobalSettings.TestCreep)
                {
                    Singleton <CreepSpawner> .Instance.CreateCreeps(new List <string>
                    {
                        "101"
                    }, info.unitId);

                    result = null;
                }
                else if (GlobalSettings.NoMonster)
                {
                    ClientLogger.Warn("P2C_CreateUnits create monster ignored");
                    result = null;
                }
                else if (info.unitType == UnitType.EyeItem)
                {
                    result = PvpProtocolTools.CreateEyeItemByUnitInfo(info);
                }
                else
                {
                    TeamType  teamType  = PvpProtocolTools.GroupToTeam((int)info.group);
                    int       num       = -1;
                    Transform transform = null;
                    if (StringUtils.CheckValid(info.burnValue))
                    {
                        string[] stringValue = StringUtils.GetStringValue(info.burnValue, '|');
                        UnitType unitType    = info.unitType;
                        if (unitType != UnitType.Monster)
                        {
                            if (unitType != UnitType.Soldier)
                            {
                                ClientLogger.Error("cannot be here");
                            }
                            else
                            {
                                num = int.Parse(stringValue[2]);
                            }
                        }
                        else
                        {
                            num       = int.Parse(stringValue[1]);
                            transform = MapManager.Instance.GetSpawnPos(TeamType.Neutral, num);
                        }
                        if (num < 0)
                        {
                            ClientLogger.Error("burnValue is invalid, use position #" + info.typeId + "  " + info.burnValue);
                        }
                    }
                    else if (info.unitType == UnitType.EyeUnit)
                    {
                        transform = MapManager.Instance.GetSpawnPos(TeamType.Neutral, 1);
                        if (transform != null)
                        {
                            transform.position = new Vector3(info.position.x, info.position.y, info.position.z);
                        }
                    }
                    else if (info.unitType == UnitType.SummonMonster || info.unitType == UnitType.BoxUnit)
                    {
                        transform = MapManager.Instance.GetSpawnPos((TeamType)info.group, 1);
                        if (transform != null)
                        {
                            transform.position = new Vector3(info.position.x, info.position.y, info.position.z);
                        }
                    }
                    else if (info.unitType == UnitType.Pet)
                    {
                        transform = MapManager.Instance.GetSpawnPos((TeamType)info.group, 1);
                        if (transform != null)
                        {
                            transform.position = new Vector3(info.position.x, info.position.y, info.position.z);
                        }
                    }
                    else if (info.unitType == UnitType.LabisiUnit)
                    {
                        transform = MapManager.Instance.GetSpawnPos((TeamType)info.group, 1);
                        if (transform != null)
                        {
                            transform.position = new Vector3(info.position.x, info.position.y, info.position.z);
                        }
                    }
                    else
                    {
                        ClientLogger.Error(string.Concat(new object[]
                        {
                            "burnValue is invalid, use default position #",
                            info.typeId,
                            "  utype:",
                            info.unitType
                        }));
                    }
                    Units unit = MapManager.Instance.GetUnit(info.mainHeroId);
                    int   skin = 0;
                    if (unit != null && info.unitType == UnitType.SummonMonster)
                    {
                        skin = HeroSkins.GetRealHeroSkin((TeamType)unit.teamType, unit.model_id);
                    }
                    EntityVo npcinfo = new EntityVo(EntityType.Monster, info.typeId, num, 0, string.Empty, "Default", 0)
                    {
                        uid  = info.unitId,
                        skin = skin
                    };
                    if (null == GameManager.Instance)
                    {
                        Debug.LogError("null == GameManager.Instance");
                        result = null;
                    }
                    else if (GameManager.Instance.Spawner == null)
                    {
                        Debug.LogError("null == GameManager.Instance.Spawner");
                        result = null;
                    }
                    else
                    {
                        SpawnUtility spawnUtility = GameManager.Instance.Spawner.GetSpawnUtility();
                        Units        units        = spawnUtility.SpawnInstance(npcinfo, "Monster", teamType, num, "[]", transform, UnitControlType.None, info.unitType);
                        if (units == null)
                        {
                            ClientLogger.Error(string.Concat(new object[]
                            {
                                "P2C_CreateUnits create monster failed, creepId=",
                                info.creepId,
                                " typeid= ",
                                info.typeId,
                                " burnValue=",
                                info.burnValue ?? "null"
                            }));
                            result = null;
                        }
                        else
                        {
                            if (units.UnitType == UnitType.EyeUnit)
                            {
                            }
                            if (unit != null)
                            {
                                units.ParentUnit = unit;
                            }
                            if (units.UnitType == UnitType.EyeUnit || units.UnitType == UnitType.SummonMonster)
                            {
                                units.m_fLiveTime = info.liveTime;
                                units.m_fLeftTime = info.liveTime;
                            }
                            units.SetOrigin(true, info.creepId.ToString(), info.monsterTeamId);
                            units.TryAddBirthEffect();
                            units.SetIsMonsterCreep(info.unitType == UnitType.Monster || info.unitType == UnitType.CreepBoss);
                            PvpProtocolTools.SyncUnitLifeStateAndSkill(units, info, 0L);
                            if (units.isMonster && units.skillManager != null)
                            {
                                units.skillManager.EnableSkills(true);
                            }
                            if (units != null && transform != null)
                            {
                                units.SetPosition(transform.position, true);
                            }
                            result = units;
                        }
                    }
                }
            }
            catch (Exception e)
            {
                ClientLogger.LogException(e);
                result = null;
            }
            return(result);
        }