示例#1
0
        public void Set(ActorNet rNetActor)
        {
            this.mNetActor = rNetActor;
            ActorProfessional rProfessional = GameConfig.Instance.GetActorProfessional(rNetActor.ProfessionalID);

            this.ActorProfession.Set(rProfessional.Name);
            this.ActorLevel.Set(rNetActor.Level);
            this.ActorName.text = rNetActor.ActorName;
        }
示例#2
0
 /// <summary>
 /// 新建一个角色
 /// </summary>
 public void CreateActor(string rActorName, int rProfessionalID, long rActorID)
 {
     this.ActiveActor = new ActorNet()
     {
         ActorID   = rActorID,
         ActorName = rActorName,
         Level     = 1,
         ServerID  = this.ServerID
     };
     this.ActiveActor.ProfessionalID = rProfessionalID;
     this.NetActors.Add(this.ActiveActor);
 }
示例#3
0
        public static ActorCreateRequest CreateActor(ActorNet rNetActor, System.Action <GameObject> rLoadCompleted = null)
        {
            if (rNetActor == null)
            {
                UtilTool.SafeExecute(rLoadCompleted, null);
                return(null);
            }
            ActorProfessional rProfessional = GameConfig.Instance.GetActorProfessional(rNetActor.ProfessionalID);

            if (rProfessional == null)
            {
                UtilTool.SafeExecute(rLoadCompleted, null);
                return(null);
            }
            return(CreateActor(rNetActor.ActorID, rProfessional.HeroID, rLoadCompleted));
        }
示例#4
0
        public async Task Create(ActorNet rNetActor, Vector3 rBornPos)
        {
            // 创建Component net
            this.CompNet          = this.AddComponent <ComponentNet>();
            this.CompNet.NetActor = rNetActor;

            // 创建Component Professional
            ActorProfessional rProfessional = GameConfig.Instance.GetActorProfessional(rNetActor.ProfessionalID);

            if (rProfessional == null)
            {
                Debug.LogErrorFormat("Cannot find professional ID: {0}", rNetActor.ProfessionalID);
                return;
            }
            this.CompPrefessional = this.AddComponent <ComponentProfessional>();
            this.CompPrefessional.Professional = rProfessional;

            // 创建Component Hero
            ActorHero rHero = GameConfig.Instance.GetHero(rProfessional.HeroID);

            if (rHero == null)
            {
                Debug.LogErrorFormat("Cannot find hero ID: {0}", rProfessional.HeroID);
                return;
            }
            this.CompHero      = this.AddComponent <ComponentHero>();
            this.CompHero.Hero = rHero;

            // 创建Component Avatar
            ActorAvatar rAvatar = GameConfig.Instance.GetAvatar(rHero.AvatarID);

            if (rAvatar == null)
            {
                Debug.LogErrorFormat("Cannot find avatar ID: {0}", rHero.AvatarID);
                return;
            }
            this.CompAvatar        = this.AddComponent <ComponentAvatar>();
            this.CompAvatar.Avatar = rAvatar;

            // 根据Avatar加载角色
            var rAvatarRequest = await AvatarAssetLoader.Instance.Load(this.CompAvatar.Avatar.ABPath, this.CompAvatar.Avatar.AssetName);

            if (rAvatarRequest.AvatarGo == null)
            {
                Debug.LogError("Avatar load failed..");
                return;
            }

            // 创建Component GameObject
            this.CompUnitGo            = this.AddComponent <ComponentUnityGo>();
            this.CompUnitGo.GameObject = rAvatarRequest.AvatarGo;

            // 创建Component Unity Animator
            this.CompUnityAnimator          = this.AddComponent <ComponentUnityAnimator>();
            this.CompUnityAnimator.Animator = rAvatarRequest.AvatarGo.GetComponent <Animator>();

            // 创建其他的Component
            this.CompAnimator = this.AddComponent <ComponentAnimator>();

            this.CompCollider        = this.AddComponent <ComponentCollider>();
            this.CompCollider.Radius = rHero.Radius;
            this.CompCollider.Height = rHero.Height;

            this.CompMove = this.AddComponent <ComponentMove>();

            this.CompTrans          = this.AddComponent <ComponentTransform>();
            this.CompTrans.Position = rBornPos;
            this.CompTrans.Forward  = Vector3.forward;
            this.CompTrans.Scale    = Vector3.one * rHero.Scale;

            this.CompInput = this.AddComponent <ComponentInput>();
        }