Exemplo n.º 1
0
        private void EnterSpawnBullet(Action _action, Track _track)
        {
            string resourceName;

            if (this.bUseSkin)
            {
                resourceName = SkinResourceHelper.GetResourceName(_action, this.prefabName, this.bUseSkinAdvance);
            }
            else
            {
                resourceName = this.prefabName;
            }
            VInt3                     vInt           = VInt3.zero;
            VInt3                     forward        = VInt3.forward;
            SkillUseContext           refParamObject = _action.refParams.GetRefParamObject <SkillUseContext>("SkillContext");
            COM_PLAYERCAMP            camp           = (refParamObject == null || !refParamObject.Originator) ? 0 : refParamObject.Originator.get_handle().TheActorMeta.ActorCamp;
            GameObject                gameObject     = _action.GetGameObject(this.parentId);
            PoolObjHandle <ActorRoot> actorHandle    = _action.GetActorHandle(this.parentId);
            PoolObjHandle <ActorRoot> actorHandle2   = _action.GetActorHandle(this.objectSpaceId);

            if (actorHandle2)
            {
                ActorRoot handle = actorHandle2.get_handle();
                if (this.superTranslation)
                {
                    VInt3 zero = VInt3.zero;
                    _action.refParams.GetRefParam("_BulletPos", ref zero);
                    vInt = IntMath.Transform(zero, handle.forward, handle.location);
                }
                else if (this.modifyTranslation)
                {
                    vInt = IntMath.Transform(this.translation, handle.forward, handle.location);
                }
                if (this.modifyDirection)
                {
                    forward = actorHandle2.get_handle().forward;
                }
            }
            else if (this.bTargetPosition)
            {
                vInt = this.translation + this.targetPosition;
                if (this.modifyDirection && refParamObject != null && refParamObject.Originator)
                {
                    forward = refParamObject.Originator.get_handle().forward;
                }
            }
            else
            {
                if (this.modifyTranslation)
                {
                    vInt = this.translation;
                }
                if (this.modifyDirection && this.direction.x != 0 && this.direction.y != 0)
                {
                    forward = this.direction;
                    forward.NormalizeTo(1000);
                }
            }
            if (this.targetId >= 0)
            {
                _action.ExpandGameObject(this.targetId);
                GameObject gameObject2 = _action.GetGameObject(this.targetId);
                if (this.recreateExisting && gameObject2 != null)
                {
                    if (this.applyActionSpeedToAnimation)
                    {
                        _action.RemoveTempObject(Action.PlaySpeedAffectedType.ePSAT_Anim, gameObject2);
                    }
                    if (this.applyActionSpeedToParticle)
                    {
                        _action.RemoveTempObject(Action.PlaySpeedAffectedType.ePSAT_Fx, gameObject2);
                    }
                    ActorHelper.DetachActorRoot(gameObject2);
                    ActionManager.DestroyGameObject(gameObject2);
                    _action.SetGameObject(this.targetId, null);
                }
                bool flag = true;
                if (!(gameObject2 == null))
                {
                    return;
                }
                if (this.bForbidBulletInObstacle && !PathfindingUtility.IsValidTarget(refParamObject.Originator.get_handle(), vInt))
                {
                    bool  flag2 = false;
                    VInt3 vInt2 = PathfindingUtility.FindValidTarget(refParamObject.Originator.get_handle(), vInt, refParamObject.Originator.get_handle().location, 10000, out flag2);
                    if (flag2)
                    {
                        VInt vInt3 = 0;
                        PathfindingUtility.GetGroundY(vInt2, out vInt3);
                        vInt2.y = vInt3.i;
                        vInt    = vInt2;
                    }
                    else
                    {
                        vInt = refParamObject.Originator.get_handle().location;
                    }
                }
                GameObject gameObject3 = MonoSingleton <SceneMgr> .GetInstance().Spawn("TempObject", SceneObjType.Bullet, vInt, forward);

                if (!gameObject3)
                {
                    throw new Exception("Age:SpawnObjectDuration Spawn Exception");
                }
                gameObject3.transform.localScale = Vector3.one;
                bool flag3       = true;
                int  particleLOD = GameSettings.ParticleLOD;
                if (GameSettings.DynamicParticleLOD)
                {
                    if (refParamObject != null && refParamObject.Originator && refParamObject.Originator.get_handle().TheActorMeta.PlayerId == Singleton <GamePlayerCenter> .GetInstance().GetHostPlayer().PlayerId)
                    {
                        flag3 = false;
                    }
                    if (!flag3 && particleLOD > 1)
                    {
                        GameSettings.ParticleLOD = 1;
                    }
                    MonoSingleton <SceneMgr> .GetInstance().m_dynamicLOD = flag3;
                }
                this.m_particleObj = MonoSingleton <SceneMgr> .GetInstance().GetPooledGameObjLOD(resourceName, true, SceneObjType.ActionRes, gameObject3.transform.position, gameObject3.transform.rotation, out flag);

                if (GameSettings.DynamicParticleLOD)
                {
                    MonoSingleton <SceneMgr> .GetInstance().m_dynamicLOD = false;
                }
                if (this.m_particleObj == null)
                {
                    if (GameSettings.DynamicParticleLOD)
                    {
                        MonoSingleton <SceneMgr> .GetInstance().m_dynamicLOD = flag3;
                    }
                    this.m_particleObj = MonoSingleton <SceneMgr> .GetInstance().GetPooledGameObjLOD(this.prefabName, true, SceneObjType.ActionRes, gameObject3.transform.position, gameObject3.transform.rotation, out flag);

                    if (GameSettings.DynamicParticleLOD)
                    {
                        MonoSingleton <SceneMgr> .GetInstance().m_dynamicLOD = false;
                    }
                }
                if (GameSettings.DynamicParticleLOD)
                {
                    GameSettings.ParticleLOD = particleLOD;
                }
                if (this.m_particleObj != null)
                {
                    this.m_particleObj.transform.SetParent(gameObject3.transform);
                    this.m_particleObj.transform.localPosition = Vector3.zero;
                    this.m_particleObj.transform.localRotation = Quaternion.identity;
                }
                this.actorRoot = ActorHelper.AttachActorRoot(gameObject3, ActorTypeDef.Actor_Type_Bullet, camp, null);
                _action.SetGameObject(this.targetId, gameObject3);
                this.actorRoot.get_handle().location = vInt;
                this.actorRoot.get_handle().forward  = forward;
                VCollisionShape.InitActorCollision(this.actorRoot, this.m_particleObj, _action.actionName);
                if (this.actorRoot.get_handle().shape != null)
                {
                    this.actorRoot.get_handle().shape.ConditionalUpdateShape();
                }
                if (this.bInvisibleBullet && this.actorRoot.get_handle().ActorControl != null)
                {
                    BulletWrapper bulletWrapper = this.actorRoot.get_handle().ActorControl as BulletWrapper;
                    if (bulletWrapper != null)
                    {
                        bulletWrapper.InitForInvisibleBullet();
                    }
                }
                this.actorRoot.get_handle().InitActor();
                if (refParamObject != null)
                {
                    refParamObject.EffectPos = this.actorRoot.get_handle().location;
                    if (this.actorRoot.get_handle().TheActorMeta.ActorType != ActorTypeDef.Actor_Type_EYE)
                    {
                        this.CreateBullet();
                    }
                }
                if (this.applyActionSpeedToAnimation)
                {
                    _action.AddTempObject(Action.PlaySpeedAffectedType.ePSAT_Anim, gameObject3);
                }
                if (this.applyActionSpeedToParticle)
                {
                    _action.AddTempObject(Action.PlaySpeedAffectedType.ePSAT_Fx, gameObject3);
                }
                this.actorRoot.get_handle().StartFight();
                if (this.enableLayer || this.enableTag)
                {
                    if (this.enableLayer)
                    {
                        gameObject3.layer = this.layer;
                    }
                    if (this.enableTag)
                    {
                        gameObject3.tag = this.tag;
                    }
                    Transform[] componentsInChildren = gameObject3.GetComponentsInChildren <Transform>();
                    for (int i = 0; i < componentsInChildren.Length; i++)
                    {
                        if (this.enableLayer)
                        {
                            componentsInChildren[i].gameObject.layer = this.layer;
                        }
                        if (this.enableTag)
                        {
                            componentsInChildren[i].gameObject.tag = this.tag;
                        }
                    }
                }
                if (flag)
                {
                    ParticleHelper.Init(gameObject3, this.scaling);
                }
                PoolObjHandle <ActorRoot> actorHandle3 = _action.GetActorHandle(this.targetId);
                this.SetParent(ref actorHandle, ref actorHandle3, this.translation);
                if (this.modifyScaling)
                {
                    gameObject3.transform.localScale = this.scaling;
                }
            }
            else
            {
                GameObject gameObject4;
                if (this.modifyDirection)
                {
                    gameObject4 = MonoSingleton <SceneMgr> .GetInstance().InstantiateLOD(this.prefabName, true, SceneObjType.ActionRes, (Vector3)vInt, Quaternion.LookRotation((Vector3)forward));
                }
                else
                {
                    gameObject4 = MonoSingleton <SceneMgr> .GetInstance().InstantiateLOD(this.prefabName, true, SceneObjType.ActionRes, (Vector3)vInt);
                }
                if (gameObject4 == null)
                {
                    return;
                }
                if (this.applyActionSpeedToAnimation)
                {
                    _action.AddTempObject(Action.PlaySpeedAffectedType.ePSAT_Anim, gameObject4);
                }
                if (this.applyActionSpeedToParticle)
                {
                    _action.AddTempObject(Action.PlaySpeedAffectedType.ePSAT_Fx, gameObject4);
                }
                if (this.enableLayer)
                {
                    gameObject4.layer = this.layer;
                    Transform[] componentsInChildren2 = gameObject4.GetComponentsInChildren <Transform>();
                    for (int j = 0; j < componentsInChildren2.Length; j++)
                    {
                        componentsInChildren2[j].gameObject.layer = this.layer;
                    }
                }
                if (this.enableTag)
                {
                    gameObject4.tag = this.tag;
                    Transform[] componentsInChildren3 = gameObject4.GetComponentsInChildren <Transform>();
                    for (int k = 0; k < componentsInChildren3.Length; k++)
                    {
                        componentsInChildren3[k].gameObject.tag = this.tag;
                    }
                }
                if (gameObject4.GetComponent <ParticleSystem>() && this.modifyScaling)
                {
                    ParticleSystem[] componentsInChildren4 = gameObject4.GetComponentsInChildren <ParticleSystem>();
                    for (int l = 0; l < componentsInChildren4.Length; l++)
                    {
                        componentsInChildren4[l].startSize            *= this.scaling.x;
                        componentsInChildren4[l].startLifetime        *= this.scaling.y;
                        componentsInChildren4[l].startSpeed           *= this.scaling.z;
                        componentsInChildren4[l].transform.localScale *= this.scaling.x;
                    }
                }
                PoolObjHandle <ActorRoot> poolObjHandle = ActorHelper.GetActorRoot(gameObject4);
                this.SetParent(ref actorHandle, ref poolObjHandle, this.translation);
                if (this.modifyScaling)
                {
                    gameObject4.transform.localScale = this.scaling;
                }
            }
        }
Exemplo n.º 2
0
        private void EnterSpawnBullet(AGE.Action _action, Track _track)
        {
            string prefabName;

            if (this.bUseSkin)
            {
                prefabName = SkinResourceHelper.GetResourceName(_action, this.prefabName, this.bUseSkinAdvance);
            }
            else
            {
                prefabName = this.prefabName;
            }
            VInt3                     zero           = VInt3.zero;
            VInt3                     forward        = VInt3.forward;
            SkillUseContext           refParamObject = _action.refParams.GetRefParamObject <SkillUseContext>("SkillContext");
            COM_PLAYERCAMP            camp           = ((refParamObject == null) || (refParamObject.Originator == 0)) ? COM_PLAYERCAMP.COM_PLAYERCAMP_MID : refParamObject.Originator.handle.TheActorMeta.ActorCamp;
            GameObject                gameObject     = _action.GetGameObject(this.parentId);
            PoolObjHandle <ActorRoot> actorHandle    = _action.GetActorHandle(this.parentId);
            PoolObjHandle <ActorRoot> handle2        = _action.GetActorHandle(this.objectSpaceId);

            if (handle2 != 0)
            {
                ActorRoot handle = handle2.handle;
                if (this.superTranslation)
                {
                    VInt3 num3 = VInt3.zero;
                    _action.refParams.GetRefParam("_BulletPos", ref num3);
                    zero = IntMath.Transform(num3, handle.forward, handle.location);
                }
                else if (this.modifyTranslation)
                {
                    zero = IntMath.Transform(this.translation, handle.forward, handle.location);
                }
                if (this.modifyDirection)
                {
                    forward = handle2.handle.forward;
                }
            }
            else if (this.bTargetPosition)
            {
                zero = this.translation + this.targetPosition;
                if ((this.modifyDirection && (refParamObject != null)) && (refParamObject.Originator != 0))
                {
                    forward = refParamObject.Originator.handle.forward;
                }
            }
            else
            {
                if (this.modifyTranslation)
                {
                    zero = this.translation;
                }
                if ((this.modifyDirection && (this.direction.x != 0)) && (this.direction.y != 0))
                {
                    forward = this.direction;
                    forward.NormalizeTo(0x3e8);
                }
            }
            if (this.targetId >= 0)
            {
                _action.ExpandGameObject(this.targetId);
                GameObject obj3 = _action.GetGameObject(this.targetId);
                if (this.recreateExisting && (obj3 != null))
                {
                    if (this.applyActionSpeedToAnimation)
                    {
                        _action.RemoveTempObject(AGE.Action.PlaySpeedAffectedType.ePSAT_Anim, obj3);
                    }
                    if (this.applyActionSpeedToParticle)
                    {
                        _action.RemoveTempObject(AGE.Action.PlaySpeedAffectedType.ePSAT_Fx, obj3);
                    }
                    ActorHelper.DetachActorRoot(obj3);
                    ActionManager.DestroyGameObject(obj3);
                    _action.SetGameObject(this.targetId, null);
                }
                GameObject go     = null;
                bool       isInit = true;
                if (obj3 == null)
                {
                    go = MonoSingleton <SceneMgr> .GetInstance().Spawn("TempObject", SceneObjType.Bullet, zero, forward);

                    if (go == null)
                    {
                        throw new Exception("Age:SpawnObjectDuration Spawn Exception");
                    }
                    go.transform.localScale = Vector3.one;
                    bool flag2       = true;
                    int  particleLOD = GameSettings.ParticleLOD;
                    if (GameSettings.DynamicParticleLOD)
                    {
                        if (((refParamObject != null) && (refParamObject.Originator != 0)) && (refParamObject.Originator.handle.TheActorMeta.PlayerId == Singleton <GamePlayerCenter> .GetInstance().GetHostPlayer().PlayerId))
                        {
                            flag2 = false;
                        }
                        if (!flag2 && (particleLOD > 1))
                        {
                            GameSettings.ParticleLOD = 1;
                        }
                        MonoSingleton <SceneMgr> .GetInstance().m_dynamicLOD = flag2;
                    }
                    this.m_particleObj = MonoSingleton <SceneMgr> .GetInstance().GetPooledGameObjLOD(prefabName, true, SceneObjType.ActionRes, go.transform.position, go.transform.rotation, out isInit);

                    if (GameSettings.DynamicParticleLOD)
                    {
                        MonoSingleton <SceneMgr> .GetInstance().m_dynamicLOD = false;
                    }
                    if (this.m_particleObj == null)
                    {
                        if (GameSettings.DynamicParticleLOD)
                        {
                            MonoSingleton <SceneMgr> .GetInstance().m_dynamicLOD = flag2;
                        }
                        this.m_particleObj = MonoSingleton <SceneMgr> .GetInstance().GetPooledGameObjLOD(this.prefabName, true, SceneObjType.ActionRes, go.transform.position, go.transform.rotation, out isInit);

                        if (GameSettings.DynamicParticleLOD)
                        {
                            MonoSingleton <SceneMgr> .GetInstance().m_dynamicLOD = false;
                        }
                    }
                    if (GameSettings.DynamicParticleLOD)
                    {
                        GameSettings.ParticleLOD = particleLOD;
                    }
                    if (this.m_particleObj != null)
                    {
                        this.m_particleObj.transform.SetParent(go.transform);
                        this.m_particleObj.transform.localPosition = Vector3.zero;
                        this.m_particleObj.transform.localRotation = Quaternion.identity;
                    }
                    this.actorRoot = ActorHelper.AttachActorRoot(go, ActorTypeDef.Actor_Type_Bullet, camp, null);
                    _action.SetGameObject(this.targetId, go);
                    this.actorRoot.handle.location = zero;
                    this.actorRoot.handle.forward  = forward;
                    VCollisionShape.InitActorCollision((ActorRoot)this.actorRoot, this.m_particleObj, _action.actionName);
                    if (this.actorRoot.handle.shape != null)
                    {
                        this.actorRoot.handle.shape.ConditionalUpdateShape();
                    }
                    this.actorRoot.handle.InitActor();
                    if (refParamObject != null)
                    {
                        refParamObject.EffectPos = this.actorRoot.handle.location;
                        if (this.actorRoot.handle.TheActorMeta.ActorType != ActorTypeDef.Actor_Type_EYE)
                        {
                            this.CreateBullet();
                        }
                    }
                    if (this.applyActionSpeedToAnimation)
                    {
                        _action.AddTempObject(AGE.Action.PlaySpeedAffectedType.ePSAT_Anim, go);
                    }
                    if (this.applyActionSpeedToParticle)
                    {
                        _action.AddTempObject(AGE.Action.PlaySpeedAffectedType.ePSAT_Fx, go);
                    }
                    this.actorRoot.handle.StartFight();
                    if (this.enableLayer || this.enableTag)
                    {
                        if (this.enableLayer)
                        {
                            go.layer = this.layer;
                        }
                        if (this.enableTag)
                        {
                            go.tag = this.tag;
                        }
                        Transform[] componentsInChildren = go.GetComponentsInChildren <Transform>();
                        for (int i = 0; i < componentsInChildren.Length; i++)
                        {
                            if (this.enableLayer)
                            {
                                componentsInChildren[i].gameObject.layer = this.layer;
                            }
                            if (this.enableTag)
                            {
                                componentsInChildren[i].gameObject.tag = this.tag;
                            }
                        }
                    }
                    if (isInit)
                    {
                        ParticleHelper.Init(go, this.scaling);
                    }
                    PoolObjHandle <ActorRoot> newActor = _action.GetActorHandle(this.targetId);
                    this.SetParent(ref actorHandle, ref newActor, this.translation);
                    if (this.modifyScaling)
                    {
                        go.transform.localScale = this.scaling;
                    }
                }
            }
            else
            {
                GameObject obj5;
                if (this.modifyDirection)
                {
                    obj5 = MonoSingleton <SceneMgr> .GetInstance().InstantiateLOD(this.prefabName, true, SceneObjType.ActionRes, (Vector3)zero, Quaternion.LookRotation((Vector3)forward));
                }
                else
                {
                    obj5 = MonoSingleton <SceneMgr> .GetInstance().InstantiateLOD(this.prefabName, true, SceneObjType.ActionRes, (Vector3)zero);
                }
                if (obj5 != null)
                {
                    if (this.applyActionSpeedToAnimation)
                    {
                        _action.AddTempObject(AGE.Action.PlaySpeedAffectedType.ePSAT_Anim, obj5);
                    }
                    if (this.applyActionSpeedToParticle)
                    {
                        _action.AddTempObject(AGE.Action.PlaySpeedAffectedType.ePSAT_Fx, obj5);
                    }
                    if (this.enableLayer)
                    {
                        obj5.layer = this.layer;
                        Transform[] transformArray2 = obj5.GetComponentsInChildren <Transform>();
                        for (int j = 0; j < transformArray2.Length; j++)
                        {
                            transformArray2[j].gameObject.layer = this.layer;
                        }
                    }
                    if (this.enableTag)
                    {
                        obj5.tag = this.tag;
                        Transform[] transformArray3 = obj5.GetComponentsInChildren <Transform>();
                        for (int k = 0; k < transformArray3.Length; k++)
                        {
                            transformArray3[k].gameObject.tag = this.tag;
                        }
                    }
                    if ((obj5.GetComponent <ParticleSystem>() != null) && this.modifyScaling)
                    {
                        ParticleSystem[] systemArray = obj5.GetComponentsInChildren <ParticleSystem>();
                        for (int m = 0; m < systemArray.Length; m++)
                        {
                            ParticleSystem system1 = systemArray[m];
                            system1.startSize *= this.scaling.x;
                            ParticleSystem system2 = systemArray[m];
                            system2.startLifetime *= this.scaling.y;
                            ParticleSystem system3 = systemArray[m];
                            system3.startSpeed *= this.scaling.z;
                            Transform transform = systemArray[m].transform;
                            transform.localScale = (Vector3)(transform.localScale * this.scaling.x);
                        }
                    }
                    PoolObjHandle <ActorRoot> actorRoot = ActorHelper.GetActorRoot(obj5);
                    this.SetParent(ref actorHandle, ref actorRoot, this.translation);
                    if (this.modifyScaling)
                    {
                        obj5.transform.localScale = this.scaling;
                    }
                }
            }
        }