예제 #1
0
 public ActorController CreateActor(SocketDataEx socket, ActorController.EFactionType factionType, Vector3 postion, Quaternion rotation)
 {
     if (socket == null || socket.GetPet() == null)
     {
         return null;
     }
     PetDataEx pet = socket.GetPet();
     if (pet == null)
     {
         return null;
     }
     string resLoc = socket.GetResLoc();
     GameObject gameObject = Res.Load<GameObject>(resLoc, false);
     if (gameObject == null)
     {
         global::Debug.LogErrorFormat("Res.Load error, path = {0}", new object[]
         {
             resLoc
         });
         return null;
     }
     GameObject gameObject2 = UnityEngine.Object.Instantiate(gameObject, postion, rotation) as GameObject;
     if (gameObject2 == null)
     {
         global::Debug.LogErrorFormat("Instantiate error, path = {0}", new object[]
         {
             pet.Info.ResLoc
         });
         return null;
     }
     if (this.senceInfo.Type == 0 || this.senceInfo.Type == 6 || this.senceInfo.Type == 7)
     {
         NJGMapItem safeComponent = Tools.GetSafeComponent<NJGMapItem>(gameObject2);
         safeComponent.type = ((!socket.IsPlayer()) ? 2 : 5);
     }
     NavMeshAgentEx safeComponent2 = Tools.GetSafeComponent<NavMeshAgentEx>(gameObject2);
     Tools.GetSafeComponent<AnimationController>(gameObject2);
     AIController safeComponent3 = Tools.GetSafeComponent<AIController>(gameObject2);
     ActorController safeComponent4 = Tools.GetSafeComponent<ActorController>(gameObject2);
     if (factionType == ActorController.EFactionType.ERed)
     {
         gameObject2.layer = LayerDefine.MonsterLayer;
     }
     if (socket.IsPlayer())
     {
         string weaponResLoc = socket.GetWeaponResLoc();
         if (!string.IsNullOrEmpty(weaponResLoc))
         {
             gameObject = Res.Load<GameObject>(weaponResLoc, false);
             if (gameObject == null)
             {
                 global::Debug.LogErrorFormat("Res.Load error, path = {0}", new object[]
                 {
                     weaponResLoc
                 });
                 return null;
             }
             GameObject gameObject3 = UnityEngine.Object.Instantiate(gameObject, postion, rotation) as GameObject;
             if (gameObject3 == null)
             {
                 global::Debug.LogErrorFormat("Instantiate error, path = {0}", new object[]
                 {
                     weaponResLoc
                 });
                 return null;
             }
             GameObject gameObject4 = ObjectUtil.FindChildObject(gameObject2, "W_Rhand");
             if (gameObject4 == null)
             {
                 global::Debug.LogError(new object[]
                 {
                     "Can not find socket : W_Rhand"
                 });
                 return null;
             }
             gameObject3.transform.parent = gameObject4.transform;
             gameObject3.transform.localPosition = Vector3.zero;
             gameObject3.transform.localRotation = Quaternion.identity;
             gameObject3.transform.localScale = Vector3.one;
         }
         safeComponent2.speed = 2.8f;
         safeComponent4.MaxRunSpeed = safeComponent2.speed;
         safeComponent4.SetData(socket, factionType);
         safeComponent3.EnableAI = false;
         safeComponent3.AttackDistance = 3f - safeComponent4.GetBoundsRadius();
         safeComponent3.Init();
         if (factionType == ActorController.EFactionType.EBlue)
         {
             this.playerCtrler = Tools.GetSafeComponent<PlayerController>(gameObject2);
             this.playerCtrler.Init();
         }
         this.CachePlayerSound(pet.Info.ElementType);
     }
     else
     {
         safeComponent2.speed = pet.Info.Speed;
         safeComponent4.MaxRunSpeed = safeComponent2.speed;
         safeComponent4.SetData(socket, factionType);
         safeComponent3.FindEnemyDistance = 6f;
         safeComponent3.AttackDistance = pet.Info.AttackDistance;
         safeComponent3.Init();
         PoolMgr.CreatePetPrefabPool(pet.Info);
     }
     return safeComponent4;
 }
예제 #2
0
 public void SetData(SocketDataEx socket, ActorController.EFactionType faction)
 {
     if (socket == null)
     {
         global::Debug.LogError(new object[]
         {
             "socket == null"
         });
         return;
     }
     PetDataEx pet = socket.GetPet();
     if (pet == null)
     {
         global::Debug.LogError(new object[]
         {
             "socket pet == null"
         });
         return;
     }
     this.SocketSlot = pet.GetSocketSlot();
     if (socket.IsPlayer())
     {
         this.actorType = ActorController.EActorType.EPlayer;
         this.ElementType = 0;
         this.playerGender = pet.Info.Type;
         this.playerName = pet.Info.Name;
     }
     else
     {
         this.actorType = ActorController.EActorType.EPet;
         this.ElementType = pet.Info.ElementType;
         this.petInfo = pet.Info;
         this.playerSkillID = pet.GetPlayerSkillID();
         int skillID = pet.GetSkillID(0);
         if (skillID != 0)
         {
             this.AddSkill(0, skillID, false);
         }
         skillID = pet.GetSkillID(1);
         if (skillID != 0)
         {
             this.AddSkill(1, skillID, false);
         }
         skillID = pet.GetSkillID(2);
         if (skillID != 0 && pet.Data.Further >= 3u)
         {
             this.AddSkill(2, skillID, false);
         }
         skillID = pet.GetSkillID(3);
         if (skillID != 0 && pet.Data.Further >= 4u)
         {
             this.AddSkill(3, skillID, false);
         }
     }
     this.factionType = faction;
     this.Level = pet.Data.Level;
     for (int i = 1; i < 11; i++)
     {
         this.attInit[i] = (long)socket.GetAtt(i);
     }
     for (int j = 1; j < 7; j++)
     {
         this.resist[j] = socket.GetResist(j);
     }
     LevelInfo info = Globals.Instance.AttDB.LevelDict.GetInfo((int)this.Level);
     if (info == null)
     {
         global::Debug.LogError(new object[]
         {
             "socket pet == null"
         });
         return;
     }
     this.MaxMP = (long)((ulong)info.MaxMP);
     for (int k = 0; k < 6; k++)
     {
         LegendSkillData legendSkill = socket.GetLegendSkill(k);
         if (legendSkill != null && legendSkill.EffectType != 0)
         {
             legendSkill.Cooldown = 0f;
             switch (legendSkill.EffectType)
             {
             case 3:
                 this.doubleDamage = legendSkill;
                 break;
             case 4:
                 this.reflexDamage = legendSkill;
                 break;
             case 5:
                 this.reduceDamage = legendSkill;
                 break;
             case 6:
                 this.damageToHeal = legendSkill;
                 break;
             case 7:
                 this.ignoreDefense = legendSkill;
                 break;
             case 8:
                 this.attackToHeal = legendSkill;
                 break;
             }
         }
     }
     this.Init();
 }