コード例 #1
0
        public void PlayUpdateRankEffect(UpdateUserRankEffectEvent evt, ReadyTankNode tank, UserRankNode user, [JoinByUser] BattleUserNode battleUser)
        {
            GameObject effectPrefab = tank.updateUserRankEffect.EffectPrefab;
            GetInstanceFromPoolEvent eventInstance = new GetInstanceFromPoolEvent {
                Prefab          = effectPrefab,
                AutoRecycleTime = effectPrefab.GetComponent <UpdateRankEffectSettings>().DestroyTimeDelay
            };

            base.ScheduleEvent(eventInstance, tank);
            Transform  instance   = eventInstance.Instance;
            GameObject gameObject = instance.gameObject;
            Transform  transform  = new GameObject("RankEffectRoot").transform;

            transform.parent        = tank.tankVisualRoot.transform;
            transform.localPosition = Vector3.zero;
            transform.localRotation = Quaternion.identity;
            transform.localScale    = Vector3.one;
            transform.gameObject.AddComponent <UpdateUserRankTransformBehaviour>().Init();
            instance.parent        = transform;
            instance.localPosition = Vector3.zero;
            instance.localRotation = Quaternion.identity;
            instance.localScale    = Vector3.one;
            foreach (UpdateRankEffectParticleMovement movement in gameObject.GetComponentsInChildren <UpdateRankEffectParticleMovement>(true))
            {
                movement.parent = transform;
            }
            transform.GetComponentInChildren <UpdateRankEffectSettings>(true).icon.SetRank(user.userRank.Rank);
            gameObject.SetActive(true);
            base.NewEvent <UpdateRankEffectFinishedEvent>().Attach(battleUser).ScheduleDelayed(tank.updateUserRankEffect.FinishEventTime);
            if (!tank.Entity.HasComponent <UpdateUserRankEffectInstantiatedComponent>())
            {
                tank.Entity.AddComponent <UpdateUserRankEffectInstantiatedComponent>();
            }
            tank.Entity.RemoveComponent <UpdateUserRankEffectReadyComponent>();
        }
コード例 #2
0
        private void CreateShaftHitSoundEffect(Vector3 position, ShaftHitSoundEffectComponent effectComponent)
        {
            GetInstanceFromPoolEvent eventInstance = new GetInstanceFromPoolEvent {
                Prefab          = effectComponent.Asset,
                AutoRecycleTime = effectComponent.Duration
            };

            base.ScheduleEvent(eventInstance, new EntityStub());
            eventInstance.Instance.position = position;
            eventInstance.Instance.rotation = Quaternion.identity;
        }
コード例 #3
0
 public void CreateEffect(CriticalEffectEvent evt, SingleNode<TankVisualRootComponent> tank, [JoinByTank] TankIncarnationWithoutCriticalEffectNode tankIncarnation)
 {
     GetInstanceFromPoolEvent eventInstance = new GetInstanceFromPoolEvent {
         Prefab = evt.EffectPrefab,
         AutoRecycleTime = evt.EffectPrefab.GetComponent<ParticleSystem>().duration
     };
     base.ScheduleEvent(eventInstance, tank);
     Transform instance = eventInstance.Instance;
     instance.parent = tank.component.transform;
     instance.localPosition = evt.LocalPosition;
     instance.gameObject.SetActive(true);
 }
コード例 #4
0
        protected void CreateHitExplosionSoundEffect(Vector3 position, GameObject prefab, float duration)
        {
            GetInstanceFromPoolEvent eventInstance = new GetInstanceFromPoolEvent {
                Prefab          = prefab,
                AutoRecycleTime = duration
            };

            base.ScheduleEvent(eventInstance, new EntityStub());
            eventInstance.Instance.position = position;
            eventInstance.Instance.rotation = Quaternion.identity;
            eventInstance.Instance.gameObject.SetActive(true);
        }
コード例 #5
0
        private void InstantiateMuzzleEffect(GameObject prefab, MuzzlePointNode muzzlePointNode, float duration)
        {
            GetInstanceFromPoolEvent eventInstance = new GetInstanceFromPoolEvent {
                Prefab          = prefab,
                AutoRecycleTime = duration
            };

            base.ScheduleEvent(eventInstance, muzzlePointNode);
            GameObject gameObject = eventInstance.Instance.gameObject;

            UnityUtil.InheritAndEmplace(gameObject.transform, muzzlePointNode.muzzlePoint.Current);
            CustomRenderQueue.SetQueue(gameObject, 0xc4e);
            gameObject.gameObject.SetActive(true);
        }
コード例 #6
0
        private AudioSource PrepareAudioSource(TankFallEvent evt, TankFallingSoundEffectComponent tankFallingSoundEffect, MapDustComponent mapDust, Transform root)
        {
            AudioSource collisionSourceAsset;

            switch (evt.FallingType)
            {
            case TankFallingType.TANK:
            case TankFallingType.VERTICAL_STATIC:
                collisionSourceAsset = tankFallingSoundEffect.CollisionSourceAsset;
                break;

            case TankFallingType.FLAT_STATIC:
            case TankFallingType.SLOPED_STATIC_WITH_TRACKS:
                collisionSourceAsset = tankFallingSoundEffect.FallingSourceAsset;
                break;

            case TankFallingType.SLOPED_STATIC_WITH_COLLISION:
            {
                DustEffectBehaviour effectByTag = mapDust.GetEffectByTag(evt.FallingTransform, Vector2.zero);
                if (effectByTag == null)
                {
                    collisionSourceAsset = tankFallingSoundEffect.FallingSourceAsset;
                }
                else
                {
                    DustEffectBehaviour.SurfaceType surface = effectByTag.surface;
                    collisionSourceAsset = ((surface == DustEffectBehaviour.SurfaceType.Metal) || (surface == DustEffectBehaviour.SurfaceType.Concrete)) ? tankFallingSoundEffect.CollisionSourceAsset : tankFallingSoundEffect.FallingSourceAsset;
                }
                break;
            }

            default:
                throw new ArgumentException("Illegal type of falling");
            }
            GetInstanceFromPoolEvent eventInstance = new GetInstanceFromPoolEvent {
                Prefab          = collisionSourceAsset.gameObject,
                AutoRecycleTime = ((collisionSourceAsset != tankFallingSoundEffect.FallingSourceAsset) ? collisionSourceAsset.clip : this.GetFallingAudioClip(tankFallingSoundEffect)).length + 0.2f
            };

            base.ScheduleEvent(eventInstance, new EntityStub());
            Transform   instance  = eventInstance.Instance;
            AudioSource component = instance.GetComponent <AudioSource>();

            instance.parent        = root;
            instance.localPosition = Vector3.zero;
            instance.localRotation = Quaternion.identity;
            instance.gameObject.SetActive(true);
            component.Play();
            return(component);
        }
コード例 #7
0
 public void EjectCase(CartridgeCaseEjectionEvent e, SingleNode <CartridgeCaseEjectorComponent> ejectorNode, [JoinByTank] HullNode hullNode, [JoinAll] SingleNode <CartridgeCaseContainerComponent> containerNode)
 {
     if (hullNode.Entity.HasComponent <SelfTankComponent>() || hullNode.cameraVisibleTrigger.IsVisibleAtRange(30f))
     {
         GetInstanceFromPoolEvent eventInstance = new GetInstanceFromPoolEvent {
             Prefab = ejectorNode.component.casePrefab
         };
         base.ScheduleEvent(eventInstance, ejectorNode);
         GameObject gameObject = eventInstance.Instance.gameObject;
         this.SetCaseTransform(gameObject, ejectorNode.component);
         this.SetCaseVelocity(gameObject, ejectorNode.component, hullNode);
         gameObject.SetActive(true);
     }
 }
コード例 #8
0
        private void DrawExplosionEffect(Vector3 position, Vector3 dir, GameObject asset, float duration, Node entity)
        {
            GetInstanceFromPoolEvent eventInstance = new GetInstanceFromPoolEvent {
                Prefab          = asset,
                AutoRecycleTime = duration
            };

            base.ScheduleEvent(eventInstance, entity);
            Transform instance = eventInstance.Instance;

            instance.position = position;
            instance.rotation = Quaternion.Euler(dir);
            instance.gameObject.SetActive(true);
            instance.gameObject.GetComponent <ParticleSystem>().Play(true);
        }
コード例 #9
0
        private void InstantiateExplosion(BulletHitEvent e, WeaponNode weaponNode)
        {
            BulletEffectComponent    bulletEffect  = weaponNode.bulletEffect;
            GetInstanceFromPoolEvent eventInstance = new GetInstanceFromPoolEvent {
                Prefab          = bulletEffect.ExplosionPrefab,
                AutoRecycleTime = bulletEffect.ExplosionTime
            };

            base.ScheduleEvent(eventInstance, weaponNode);
            GameObject gameObject = eventInstance.Instance.gameObject;

            gameObject.transform.position = e.Position;
            gameObject.transform.rotation = Quaternion.identity;
            gameObject.SetActive(true);
        }
コード例 #10
0
        public void CreateAndPlayGoldNotificationSound(NodeAddedEvent evt, GoldNotificationSoundListenerNode listener, [JoinAll] SingleNode <MapInstanceComponent> map, [JoinAll] SingleNode <GoldSoundConfigComponent> config)
        {
            listener.Entity.RemoveComponent <GoldNotificationPlaySoundComponent>();
            AudioSource goldNotificationSound      = config.component.GoldNotificationSound;
            GetInstanceFromPoolEvent eventInstance = new GetInstanceFromPoolEvent {
                Prefab          = goldNotificationSound.gameObject,
                AutoRecycleTime = goldNotificationSound.clip.length
            };

            base.ScheduleEvent(eventInstance, listener);
            Transform instance = eventInstance.Instance;

            instance.SetParent(map.component.SceneRoot.transform);
            instance.gameObject.SetActive(true);
            instance.GetComponent <AudioSource>().Play();
        }
コード例 #11
0
        public void CreateAndPlayBonusTakingSound(NodeAddedEvent e, SingleNode <BrokenBonusBoxInstanceComponent> bonus, [JoinAll] SingleNode <BonusSoundConfigComponent> bonusClientConfig, [JoinAll] SingleNode <SoundListenerBattleStateComponent> soundListener)
        {
            AudioSource bonusTakingSound           = bonusClientConfig.component.BonusTakingSound;
            GetInstanceFromPoolEvent eventInstance = new GetInstanceFromPoolEvent {
                Prefab          = bonusTakingSound.gameObject,
                AutoRecycleTime = bonusTakingSound.clip.length + 0.5f
            };

            base.ScheduleEvent(eventInstance, bonus);
            Transform instance  = eventInstance.Instance;
            Transform transform = bonus.component.Instance.transform;

            instance.position = transform.position;
            instance.rotation = transform.rotation;
            instance.gameObject.SetActive(true);
            instance.GetComponent <AudioSource>().Play();
        }
コード例 #12
0
        public void PlayExplosionSound(MineExplosionEvent e, IceTrapNode effect, [JoinAll] SingleNode <SoundListenerBattleStateComponent> soundListener)
        {
            Transform transform = effect.effectInstance.GameObject.transform;
            GetInstanceFromPoolEvent eventInstance = new GetInstanceFromPoolEvent {
                Prefab          = effect.iceTrapExplosionSound.ExplosionSoundAsset,
                AutoRecycleTime = effect.iceTrapExplosionSound.Lifetime
            };

            base.ScheduleEvent(eventInstance, effect);
            Transform  instance   = eventInstance.Instance;
            GameObject gameObject = instance.gameObject;

            instance.position = transform.position;
            instance.rotation = transform.rotation;
            gameObject.SetActive(true);
            Object.DontDestroyOnLoad(gameObject);
        }
コード例 #13
0
        public virtual void PlayEffect(Vector3 position)
        {
            GetInstanceFromPoolEvent eventInstance = new GetInstanceFromPoolEvent {
                Prefab          = this.assetSource.gameObject,
                AutoRecycleTime = this.lifetime
            };

            base.ScheduleEvent(eventInstance, new EntityStub());
            Transform instance = eventInstance.Instance;

            instance.position = position;
            instance.rotation = Quaternion.identity;
            AudioSource component = instance.GetComponent <AudioSource>();

            component.gameObject.SetActive(true);
            this.Play(component);
        }
コード例 #14
0
        private void PlayEffect(ParticleSystem prefab, Transform visualRoot, Transform mountPoint, float timeToPlay, Node entity)
        {
            GetInstanceFromPoolEvent eventInstance = new GetInstanceFromPoolEvent {
                Prefab          = prefab.gameObject,
                AutoRecycleTime = Mathf.Min(timeToPlay, prefab.main.duration)
            };

            base.ScheduleEvent(eventInstance, entity);
            Transform  instance   = eventInstance.Instance;
            GameObject gameObject = instance.gameObject;

            instance.parent        = visualRoot;
            instance.localPosition = mountPoint.localPosition;
            instance.rotation      = Quaternion.identity;
            gameObject.SetActive(true);
            gameObject.GetComponent <ParticleSystem>().Play(true);
        }
コード例 #15
0
        public void SpawnExplosionOnBounce(UpdateBulletEvent e, BulletNode bulletNode, [JoinByTank] WeaponNode weaponNode)
        {
            BulletEffectComponent bulletEffect = weaponNode.bulletEffect;
            DirectionData         data         = e.TargetingData.Directions.First <DirectionData>();

            if (data.StaticHit != null)
            {
                GetInstanceFromPoolEvent eventInstance = new GetInstanceFromPoolEvent {
                    Prefab          = bulletEffect.ExplosionPrefab,
                    AutoRecycleTime = bulletEffect.ExplosionTime
                };
                base.ScheduleEvent(eventInstance, new EntityStub());
                Transform instance = eventInstance.Instance;
                instance.position = data.StaticHit.Position + (data.StaticHit.Normal * bulletEffect.ExplosionOffset);
                instance.rotation = Quaternion.LookRotation(data.StaticHit.Normal);
                instance.gameObject.SetActive(true);
            }
        }
コード例 #16
0
        public void Build(NodeAddedEvent e, BulletNode node, [JoinBy(typeof(TankGroupComponent))] WeaponNode weaponNode)
        {
            BulletComponent bullet     = node.bullet;
            Quaternion      quaternion = Quaternion.LookRotation(bullet.Direction);
            BulletEffectInstanceComponent component     = new BulletEffectInstanceComponent();
            GetInstanceFromPoolEvent      eventInstance = new GetInstanceFromPoolEvent {
                Prefab = weaponNode.bulletEffect.BulletPrefab
            };

            base.ScheduleEvent(eventInstance, node);
            GameObject gameObject = eventInstance.Instance.gameObject;

            gameObject.transform.position = bullet.Position;
            gameObject.transform.rotation = quaternion;
            gameObject.SetActive(true);
            component.Effect = gameObject;
            CustomRenderQueue.SetQueue(gameObject, 0xc4e);
            node.Entity.AddComponent(component);
        }
コード例 #17
0
        private void StartRailgunChargingByBaseEvent(BaseRailgunChargingShotEvent evt, RailgunChargingNode muzzle, TankActiveNode tank)
        {
            RailgunChargingWeaponComponent railgunChargingWeapon = muzzle.railgunChargingWeapon;
            GetInstanceFromPoolEvent       eventInstance         = new GetInstanceFromPoolEvent {
                Prefab          = muzzle.railgunChargingEffect.Prefab,
                AutoRecycleTime = railgunChargingWeapon.ChargingTime
            };

            base.ScheduleEvent(eventInstance, muzzle);
            Transform  instance   = eventInstance.Instance;
            GameObject gameObject = instance.gameObject;

            CustomRenderQueue.SetQueue(gameObject, 0xc4e);
            ParticleSystem component = gameObject.GetComponent <ParticleSystem>();

            component.main.startLifetime = railgunChargingWeapon.ChargingTime;
            component.emission.enabled   = true;
            UnityUtil.InheritAndEmplace(instance, muzzle.muzzlePoint.Current);
            gameObject.SetActive(true);
            base.CreateEntity("railgun_charging").AddComponent(new TankGroupComponent(tank.Entity));
        }
コード例 #18
0
 public void PlaceRegions(NodeAddedEvent e, [Combine] BonusRegionBuildNode region, SingleNode <MapInstanceComponent> map)
 {
     if (region.resourceData.Data != null)
     {
         GetInstanceFromPoolEvent eventInstance = new GetInstanceFromPoolEvent {
             Prefab = region.resourceData.Data as GameObject
         };
         base.ScheduleEvent(eventInstance, region);
         Transform instance = eventInstance.Instance;
         instance.position = region.spatialGeometry.Position;
         instance.rotation = Quaternion.Euler(region.spatialGeometry.Rotation);
         GameObject gameObject = instance.gameObject;
         gameObject.SetActive(true);
         Animation component = gameObject.GetComponent <Animation>();
         if (component != null)
         {
             component[component.clip.name].normalizedTime = Random.value;
         }
         region.Entity.AddComponent(new BonusRegionInstanceComponent(gameObject));
     }
 }
コード例 #19
0
 public void GetInstanceFromContainer(GetInstanceFromPoolEvent e, Node any, [JoinAll] Optional <MapWithContainer> map)
 {
     if (!map.IsPresent())
     {
         e.Instance = Object.Instantiate <GameObject>(e.Prefab).transform;
         if (e.AutoRecycleTime > 0f)
         {
             Object.Destroy(e.Instance.gameObject, e.AutoRecycleTime);
         }
     }
     else
     {
         PoolContainer container;
         MainPoolContainerComponent mainPoolContainer = map.Get().mainPoolContainer;
         if (!mainPoolContainer.PrefabToPoolDict.TryGetValue(e.Prefab, out container))
         {
             Transform transform = new GameObject(e.Prefab.name + "_PoolContainer").transform;
             transform.SetParent(mainPoolContainer.MainContainerTransform);
             PoolContainer container2 = transform.gameObject.AddComponent <PoolContainer>();
             container2.ItemsRoot    = transform;
             container2.CustomPrefab = e.Prefab;
             container = container2;
             mainPoolContainer.PrefabToPoolDict.Add(e.Prefab, container2);
         }
         Transform poolTransform = container.Get().PoolTransform;
         e.Instance = poolTransform;
         if (e.AutoRecycleTime > 0f)
         {
             RecycleAfterTime component = poolTransform.gameObject.GetComponent <RecycleAfterTime>();
             if (component)
             {
                 component.Timeout = e.AutoRecycleTime;
             }
             else
             {
                 poolTransform.gameObject.AddComponent <RecycleAfterTime>().Timeout = e.AutoRecycleTime;
             }
         }
     }
 }
コード例 #20
0
        public void CreateBrokenBonusBox(BonusTakenEvent e, BonusWithResourceNode bonus, [JoinAll] SingleNode <BonusClientConfigComponent> bonusConfig)
        {
            Transform transform = bonus.bonusBoxInstance.BonusBoxInstance.transform;
            GetInstanceFromPoolEvent eventInstance = new GetInstanceFromPoolEvent {
                Prefab = bonus.bonusBoxInstance.BonusBoxInstance.GetComponent <BrokenBonusBoxBehavior>().BrokenBonusGameObject
            };

            base.ScheduleEvent(eventInstance, bonus);
            Transform  instance   = eventInstance.Instance;
            GameObject gameObject = instance.gameObject;

            instance.position = transform.position;
            instance.rotation = transform.rotation;
            Material[] allMaterials = MaterialAlphaUtils.GetAllMaterials(gameObject);
            allMaterials.SetOverrideTag("RenderType", "Transparent");
            Entity entity = base.CreateEntity("brokenBonusBox");

            entity.AddComponent(new MaterialArrayComponent(allMaterials));
            entity.AddComponent(new BrokenBonusBoxInstanceComponent(gameObject));
            entity.AddComponent <BonusTakingStateComponent>();
            entity.AddComponent(new LocalDurationComponent(bonusConfig.component.disappearingDuration));
            gameObject.SetActive(true);
        }