Beispiel #1
0
    public static RobotCreature Create(CreatureInfo info, Vector3_ pos, Vector3 rot, string name = "", string uiName = "")
    {
        if (info == null)
        {
            Logger.LogError("RobotCreature::Create: Create robot failed, invalid config");
            return(null);
        }

        var rootNode = new GameObject().transform;

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

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

        // Protect invalid weapon config
        if (info.weaponID < 1)
        {
            info.weaponID     = 1;
            info.weaponItemID = 1101;
        }

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

        c.InitPosition(pos);
        c.isPlayer     = false;
        c.isMonster    = false;
        c.isRobot      = true;
        c.isCombat     = true;
        c.creatureCamp = CreatureCamp.MonsterCamp;  // 机器人默认必须是怪物的阵营
        c.uiName       = string.IsNullOrEmpty(uiName) ? c.name : uiName;

        c.isDead        = false;
        c.realDead      = false;
        c.useSpringBone = true;
        c.teamIndex     = MonsterCreature.GetMonsterRoomIndex();

        c.UpdateConfig(info);
        c.OnCreate(info.buffs);

        return(c);
    }
Beispiel #2
0
    public static FlyingEffect Create(StateMachineInfo.FlyingEffect effInfo, Creature source, int overrideForward, bool invert, StateMachineInfo.Effect hitEffect, Vector3_ root, Vector3_ rootEular, Vector3 rootRot)
    {
        var fe = ConfigManager.Get <FlyingEffectInfo>(effInfo.effect);

        if (!fe)
        {
            Logger.LogWarning("FlyingEffect::Create: Could not create flying effect [{0}], could not find effect config from config_flyingEffectInfos", effInfo.effect);
            return(null);
        }

        FightRecordManager.RecordLog <LogString>(log =>
        {
            log.tag   = (byte)TagType.CreateFlyEffect;
            log.value = fe.effect;
        });

        var off = effInfo.offset * 0.1;

        if (invert)
        {
            off.x = -off.x;
            off.z = -off.z;
        }

        var direction = effInfo.direction;
        var rotation  = effInfo.rotation;

        direction.Set(direction.z, direction.y, -direction.x);
        rotation.Set(-rotation.x, rotation.y, rotation.z);

        var eular = rootEular + direction;

        eular.z = Mathd.ClampAngle(eular.z);

        var z   = Mathd.AngToRad(eular.z);
        var dir = new Vector3_(Mathd.Cos(z), -Mathd.Sin(z));
        var pos = root + off;
        var eff = Create <FlyingEffect>(fe.effect, fe.effect, pos, rotation);

        eff.enableUpdate = true;

        if (invert)
        {
            dir.x = -dir.x;
        }

        eff.sourceBuff = null;
        eff.follow     = false;
        eff.m_inherit  = false;
        eff.m_time     = 0;

        eff.m_originEular = eff.localEulerAngles;
        eff.lockForward   = Vector3.zero;
        eff.startForward  = overrideForward == 0 ? !source || source.isForward : overrideForward > 0;

        eff.m_curSectionIdx     = 0;
        eff.m_curActivedSection = -1;
        eff.m_curSubEffectIdx   = 0;
        eff.m_curSoundEffectIdx = 0;
        eff.m_curShakeIdx       = 0;
        eff.m_groundHited       = false;
        eff.m_renderTime        = 0;

        eff.effectInfo   = fe;
        eff.source       = source;
        eff.position_    = pos;
        eff.velocity     = effInfo.velocity * 0.0001;
        eff.acceleration = effInfo.acceleration * 0.0001;
        eff.lifeTime     = fe.lifeTime;
        eff.hitEffect    = hitEffect;

        eff.CreateCollider(rootRot, dir, eular);

        eff.m_inverted = invert;
        eff.UpdateInvert();

#if AI_LOG
        eff.logId = MonsterCreature.GetMonsterRoomIndex();
        Module_AI.LogBattleMsg(source, "create a flying effect[logId:{0}] with pos {1}, lifeTime = {2}  startForward is {3}", eff.logId, eff.position_, eff.lifeTime, eff.startForward);
#endif
        return(eff);
    }
Beispiel #3
0
    public static FollowTargetEffect Create(StateMachineInfo.FollowTargetEffect effInfo, Transform node, Creature target, Vector3_ position,
                                            Creature source = null, Buff sourceBuff = null)
    {
        var eff = Create <FollowTargetEffect>(effInfo.effect, effInfo.effect, position + effInfo.motionData.offset,
                                              (node.rotation * Quaternion.Euler(effInfo.rotation)).eulerAngles);

        eff.enableUpdate   = true;
        eff.source         = source;
        eff.follow         = false;
        eff.m_time         = 0;
        eff.offset         = effInfo.motionData.offset;
        eff.target         = target;
        eff.sourceBuff     = sourceBuff;
        eff.triggerType    = effInfo.triggerType;
        eff.m_originEular  = eff.localEulerAngles;
        eff.localScale     = effInfo.scale;
        eff.velocity       = effInfo.motionData.velocity;
        eff.acceleration   = effInfo.motionData.acceleration;
        eff.randomPosition = eff.position_ = position + effInfo.motionData.offset;
        eff.motion         = new Motion_SlantingThrow(eff, target, effInfo.motionData);
        eff.lifeTime       = -1;
        //粒子系统要更改粒子节点才能改其缩放。搞不懂为什么
        var particles = eff.transform.GetComponentsInChildren <ParticleSystem>();

        if (particles != null && particles.Length > 0)
        {
            for (var i = 0; i < particles.Length; i++)
            {
                particles[i].transform.localScale = effInfo.scale;
            }
        }

        eff.transform.SetParent(null);

        if (effInfo.randomPosition)
        {
            var p = eff.position_;
            eff.randomPosition = new Vector3_(p.x + 1.5 * moduleBattle._Range(-1.0, 1.0), p.y + 1.5 * moduleBattle._Range(0, 1.0));
            eff.startPos       = eff.randomPosition;
        }
        else
        {
            eff.startPos = eff.position_;
        }


        if (sourceBuff != null)
        {
            eff.m_buffCheck = sourceBuff.version;
            eff.lifeTime    = -1;
        }
        else
        {
            eff.m_buffCheck = 0;
        }

        eff.m_inverted = source && !source.isForward;
        eff.UpdateInvert();

        eff.InitTrigger();

#if AI_LOG
        eff.logId = MonsterCreature.GetMonsterRoomIndex();
        Module_AI.LogBattleMsg(source, "create a FollowTargetEffect[logId: {0}] with target {0} startPos {1}, lifeTime = {1}  startForward is {2}", eff.logId, eff.position_, eff.lifeTime, eff.startForward);
#endif

        return(eff);
    }
Beispiel #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);
    }