Ejemplo n.º 1
0
 public override bool Initialize(params object[] p)
 {
     moduleHome.HideOthers(PET_OBJECT_NAME);
     if (base.Initialize())
     {
         SelectPet = null;
         PetInfo defaultPet = null;
         if (p.Length > 0)
         {
             defaultPet = modulePet.GetPet((int)p[0]);
             if (defaultPet != null)
             {
                 OnSelectChange(defaultPet, null);
             }
         }
         petSelectModule.Initalize(Module_Pet.GetAllPet(), defaultPet);
         talkButton?.onClick.AddListener(OnTease);
         fightButton?.onClick.AddListener(OnPetFight);
         restButton?.onClick.AddListener(RestButton);
         skillButton?.onClick.AddListener(() =>
         {
             if (SelectPet == null)
             {
                 Logger.LogError("检测到bug。SelectPet为空!");
                 return;
             }
             moduleGlobal.UpdateSkillTip(SelectPet.GetSkill(), SelectPet.AdditiveLevel, SelectPet.Mood);
         });
     }
     return(true);
 }
Ejemplo n.º 2
0
    private void RefreshSkill()
    {
        if (SelectPet == null)
        {
            return;
        }
        var skill = SelectPet.GetSkill();

        if (skill == null)
        {
            return;
        }
        AtlasHelper.SetShared(skillIcon, skill.skillIcon);
        Util.SetText(skillDescText, SelectPet.SkillName);
    }
Ejemplo n.º 3
0
    public static void BuildPetPreloadAssets(List <string> assets, PetInfo pet)
    {
        if (pet == null)
        {
            return;
        }

        var creatureInfo = pet.BuildCreatureInfo();

        assets.AddRange(creatureInfo.models);

        //pet weapons
        BuildWeaponPreloadAssets(0, 1, creatureInfo.weaponID, creatureInfo.weaponItemID, creatureInfo.offWeaponID, creatureInfo.offWeaponItemID, assets);

        var skill = pet.GetSkill();

        if (skill != null && skill.buffs != null)
        {
            BuildBuffPreloadAssets(skill.buffs, assets);
        }
    }
Ejemplo n.º 4
0
    public static PetCreature Create(Creature parent, PetInfo info, Vector3_ pos, Vector3 rot, bool player = false, string name = "", string uiName = "", bool combat = true, bool useSpringBone = true)
    {
        if (info == null)
        {
            Logger.LogError("PetCreature::Create: Create pet failed, invalid config info");
            return(null);
        }

        var petInfo = info.BuildCreatureInfo();

        if (petInfo == null)
        {
            Logger.LogError("PetCreature::Create Create pet [{0}] failed, invalid config info", info.ID);
            return(null);
        }

        var rootNode = new GameObject().transform;

        if (!CreateMorphNodes(petInfo, rootNode))
        {
            Logger.LogError("PetCreature::Create: Create pet [{0}:{1}] failed, main model [{2}] not loaded", info.ID, petInfo.name, CreatureInfo.GetMorphModelName(petInfo.models, 0));
            return(null);
        }

        rootNode.position    = pos;
        rootNode.eulerAngles = rot;

        var c = Create <PetCreature>(string.IsNullOrEmpty(name) ? petInfo.name : name, rootNode.gameObject);

        c.InitPosition(pos);
        c.petInfo        = info;
        c.ParentCreature = parent;
        c.isPlayer       = player;
        c.isMonster      = false;
        c.isCombat       = combat;
        c.isRobot        = false;
        c.creatureCamp   = parent ? parent.creatureCamp : CreatureCamp.PlayerCamp;
        c.uiName         = string.IsNullOrEmpty(uiName) ? c.name : uiName;
        c.isDead         = false;
        c.realDead       = false;
        c.useSpringBone  = useSpringBone;

        c.UpdateConfig(petInfo);

        c.behaviour.UpdateAllColliderState(false);
        c.behaviour.attackCollider.enabled = true;
        c.teamIndex = MonsterCreature.GetMonsterRoomIndex();

        c.Buffs = info.GetBuff(info.AdditiveLevel);
        c.OnCreate(info.GetInitBuff());


        c.avatar = info.UpGradeInfo.icon;
        c.skills.Clear();
        var skill = info.GetSkill();

        if (skill != null)
        {
            c.skills.Add(skill.state, PetSkillData.Create(skill));
        }
        return(c);
    }