Example #1
0
    protected override void OnCreateCreatures()
    {
        m_isEnding = false;

        EventManager.AddEventListener(CreatureEvents.DEAD, OnCreatureDead);

        if (!moduleAI.IsStartAI)
        {
            moduleAI.StartAI();
        }

        var players = LoadParam.players;

        for (var i = 0; i < players.Length; ++i)
        {
            var pi       = players[i];
            var info     = modulePlayer.BuildPlayerInfo(pi);
            var isPlayer = pi.roleId == LoadParam.MasterId;
            var pos      = new Vector3_(i == 0 ? CombatConfig.spvpStart.x : CombatConfig.spvpStart.y, 0, 0);

            var p = isPlayer || !LoadParam.IsMatchRobot ? Creature.Create(info, pos, new Vector3(0, 90, 0), isPlayer, i + ":" + pi.roleId, pi.roleName) : RobotCreature.Create(info, pos, new Vector3(0, 90, 0), i + ":" + pi.roleId, pi.roleName);

            if (i != 0)
            {
                p.direction = CreatureDirection.BACK;
            }

            p.roleId       = pi.roleId;
            p.roleProto    = pi.roleProto;
            p.teamIndex    = i;
            p.avatar       = pi.avatar;
            p.enableUpdate = false;

            if (isPlayer)
            {
                m_player = p;
            }

            m_players.Add(p);

            if (LoadParam.IsMatchRobot)
            {
                if (!isPlayer)
                {
                    moduleAI.AddPlayerAI(p);
                }
                moduleAI.AddCreatureToCampDic(p);
            }

            CharacterEquip.ChangeCloth(p, pi.fashion);

            if (pi.pet != null && pi.pet.itemTypeId != 0)
            {
                var show = ConfigManager.Get <ShowCreatureInfo>(pi.pet.itemTypeId);
                if (show == null)
                {
                    Logger.LogError("没有配置config_showCreatureInfo表。宠物ID = {0}, 没有出生位置信息。宠物模型创建失败", pi.pet.itemTypeId);
                    continue;
                }

                var showData = show.GetDataByIndex(0);
                var data     = showData.data.GetValue <ShowCreatureInfo.SizeAndPos>(0);
                p.pet = PetCreature.Create(p, PetInfo.Create(pi.pet), p.position_ + data.pos, p.eulerAngles, false, Module_Home.PET_OBJECT_NAME);
                p.pet.enableUpdate = false;

                if (!moduleAI.IsStartAI)
                {
                    moduleAI.StartAI();
                }
                moduleAI.AddPetAI(p.pet);
            }
        }

        combatCamera.enabled = false;
        combatCamera.LookTo(new Vector3((float)((CombatConfig.spvpStart.x + CombatConfig.spvpStart.y) * 0.5), 0, 0));
    }
Example #2
0
    protected override void OnCreateCreatures()
    {
        base.OnCreateCreatures();
        EventManager.AddEventListener(CreatureEvents.DEAD, OnCreatureDead);

        //进入迷宫的时候要还原血量
        if (modulePVE.reopenPanelType == PVEReOpenPanel.Labyrinth)
        {
            int damage = (int)(player.maxHealth * (1.0f - moduleLabyrinth.labyrinthSelfInfo.healthRate / 100f));
            player.TakeDamage(null, DamageInfo.CreatePreCalculate(damage));
            player.rage = moduleLabyrinth.labyrinthSelfInfo.angerRate;

            //Logger.LogDetail("进入关卡赋值血量和怒气health = {0},anger = {1}", player.healthRate, player.rageRate);
        }

        moduleAI.StartAI();

        if (m_player.pet != null)
        {
            moduleAI.AddPetAI(m_player.pet);
        }

        //创建机器人
        int      enermyCreatureId = moduleLabyrinth.lastSneakPlayer.GetProto();
        PFashion enermyFashion    = moduleLabyrinth.sneakPlayerDetail.fashion;

        m_enermy = RobotCreature.CreateRobot(enermyCreatureId, Vector3.zero + Vector3.right * 5, new Vector3(0f, 90f, 0f), enermyFashion.weapon, enermyFashion.gun, "hero2", moduleLabyrinth.lastSneakPlayer.roleName);
        m_enermy.gameObject.name = "enermy_robot";
        m_enermy.direction       = CreatureDirection.BACK;
        m_enermy.avatar          = moduleLabyrinth.lastSneakPlayer.avatar;
        m_enermy.roleProto       = enermyCreatureId;

        CharacterEquip.ChangeCloth(m_enermy, moduleLabyrinth.sneakPlayerDetail.fashion);
        //重置属性
        ((RobotCreature)m_enermy).ResetRobotAttribute(moduleLabyrinth.sneakPlayerDetail.roleAttrs, enermyFashion);

        //创建宠物
        PItem pet = moduleLabyrinth.lastSneakPlayer.pet;

        if (pet != null && pet.itemTypeId != 0)
        {
            var show = ConfigManager.Get <ShowCreatureInfo>(pet.itemTypeId);
            if (show == null)
            {
                Logger.LogError("没有配置config_showCreatureInfo表。宠物ID = {0}, 没有出生位置信息。宠物模型创建失败", pet.itemTypeId);
            }

            var showData = show.GetDataByIndex(0);
            var data     = showData.data.GetValue <ShowCreatureInfo.SizeAndPos>(0);
            m_enermy.pet = PetCreature.Create(m_enermy, PetInfo.Create(pet), m_enermy.position_ + data.pos, m_enermy.eulerAngles, false, Module_Home.PET_OBJECT_NAME);

            moduleAI.AddPetAI(m_enermy.pet);
        }

        //设置被偷袭玩家BUFF
        if (moduleLabyrinth.sneakPlayerDetail.buffs != null)
        {
            ushort[] buffIds = moduleLabyrinth.sneakPlayerDetail.buffs;
            for (int i = 0, length = buffIds.Length; i < length; i++)
            {
                Buff.Create(buffIds[i], m_enermy);
            }
        }
        moduleAI.AddCreatureToCampDic(m_enermy);
        moduleAI.AddCreatureToCampDic(player);
        moduleAI.AddPlayerAI(m_enermy);

        combatCamera.enabled = false;
        combatCamera.LookTo(new Vector3((float)((CombatConfig.spvpStart.x + CombatConfig.spvpStart.y) * 0.5), 0, 0));

        //set initial health and rage
        modulePVE.SetPveGameData(EnumPVEDataType.Health, m_player.healthRate);
        modulePVE.SetPveGameData(EnumPVEDataType.Rage, m_player.rageRate);
    }