Ejemplo n.º 1
0
        public void StartLoad()
        {
            ActorProfessional rProfessional = GameConfig.Instance.GetActorProfessional(this.ProfessionalID);

            this.Parent.ProfessionalDesc.text = rProfessional.Desc;
            mActorCreateRequest = ActorCreater.CreateActor(-1, rProfessional.HeroID, ActorLoadCompleted);
        }
Ejemplo n.º 2
0
        public ActorProfessional GetActorProfessional(int rProfessionID)
        {
            ActorProfessional rProfessional = null;

            this.ActorProfessionals.TryGetValue(rProfessionID, out rProfessional);
            return(rProfessional);
        }
Ejemplo n.º 3
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;
        }
Ejemplo n.º 4
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));
        }
Ejemplo n.º 5
0
 public void OnValueChanged()
 {
     if (this.SelectedToggle.isOn && this.Parent.SelectedPlayerItem != this)
     {
         StopLoad();
         Account.Instance.ActiveActor   = this.mNetActor;
         this.Parent.SelectedPlayerItem = this;
         ActorProfessional rProfessional = GameConfig.Instance.GetActorProfessional(this.mNetActor.ProfessionalID);
         mActorCreateRequest = ActorCreater.CreateActor(this.mNetActor.ActorID, rProfessional.HeroID, ActorLoadCompleted);
     }
     else if (!this.SelectedToggle.isOn)
     {
         ActorCreater.DestoryActor(mActorCreateRequest.Hero.ID);
         UtilTool.SafeDestroy(mActorCreateRequest.ActorGo);
         mActorCreateRequest.Stop();
     }
 }
Ejemplo n.º 6
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>();
        }