Ejemplo n.º 1
0
 public void InitLaser(NodeAddedEvent e, SelfActiveTankNode activeTank, [JoinByTank] WeaponWithLaser weapon, [JoinAll] SingleNode <LaserSightSettingsComponent> settings)
 {
     if (settings.component.Enabled)
     {
         GameObject asset = weapon.shaftAimingLaser.Asset;
         for (int i = 0; i < weapon.muzzlePoint.Points.Length; i++)
         {
             GetInstanceFromPoolEvent eventInstance = new GetInstanceFromPoolEvent {
                 Prefab = asset
             };
             base.ScheduleEvent(eventInstance, activeTank);
             Transform  instance   = eventInstance.Instance;
             GameObject gameObject = instance.gameObject;
             ShaftAimingLaserBehaviour component = gameObject.GetComponent <ShaftAimingLaserBehaviour>();
             weapon.shaftAimingLaser.EffectInstance = component;
             CustomRenderQueue.SetQueue(gameObject, 0xc4e);
             Transform transform = weapon.weaponInstance.WeaponInstance.transform;
             instance.position = transform.position;
             instance.rotation = transform.rotation;
             gameObject.SetActive(true);
             component.Init();
             component.SetColor(Color.red);
             component.Show();
         }
         weapon.Entity.AddComponent <ShaftAimingLaserReadyComponent>();
     }
 }
Ejemplo n.º 2
0
        private void PlaySound(AudioSource soundPrefab, Vector3 position)
        {
            GetInstanceFromPoolEvent eventInstance = new GetInstanceFromPoolEvent {
                Prefab          = soundPrefab.gameObject,
                AutoRecycleTime = soundPrefab.clip.length
            };

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

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

            component.gameObject.SetActive(true);
            component.Play();
        }
Ejemplo n.º 3
0
        public void BuildBonusBox(NodeAddedEvent e, [Combine] BonusBoxBuildNode bonus, [Context, JoinByBattle] BonusClientConfigNode bonusClientConfig, [Context, JoinByMap] MapEffectNode mapEffect)
        {
            GetInstanceFromPoolEvent eventInstance = new GetInstanceFromPoolEvent {
                Prefab = (GameObject)bonus.resourceData.Data
            };

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

            gameObject.AddComponent <BonusPhysicsBehaviour>().TriggerEntity = bonus.Entity;
            BonusBoxInstanceComponent component = new BonusBoxInstanceComponent {
                BonusBoxInstance = gameObject
            };

            bonus.Entity.AddComponent(component);
            gameObject.SetActive(true);
        }
Ejemplo n.º 4
0
 public void BuildParachuteIfNeed(NodeAddedEvent e, [Combine] BonusBoxDataNode bonus, ParachuteMapEffectNode mapEffect)
 {
     if (IsUnderCeil(bonus.position.Position) || this.IsOnGround(bonus.position.Position, bonus.bonusData, bonus.bonusDropTime))
     {
         bonus.Entity.AddComponent <BonusSpawnOnGroundStateComponent>();
         bonus.Entity.AddComponent <BonusGroundedStateComponent>();
         bonus.Entity.AddComponent <BonusSpawnStateComponent>();
     }
     else
     {
         GetInstanceFromPoolEvent eventInstance = new GetInstanceFromPoolEvent {
             Prefab = mapEffect.bonusParachuteMapEffect.Parachute
         };
         base.ScheduleEvent(eventInstance, bonus);
         Transform  instance   = eventInstance.Instance;
         GameObject gameObject = instance.gameObject;
         instance.parent        = bonus.bonusBoxInstance.BonusBoxInstance.transform;
         instance.localPosition = new Vector3(0f, bonus.bonusData.BoxHeight, 0f);
         instance.rotation      = Quaternion.identity;
         instance.localScale    = Vector3.one;
         IEnumerator enumerator = instance.GetEnumerator();
         try
         {
             while (enumerator.MoveNext())
             {
                 Transform current = (Transform)enumerator.Current;
                 current.localRotation = Quaternion.identity;
             }
         }
         finally
         {
             IDisposable disposable = enumerator as IDisposable;
             if (disposable != null)
             {
                 disposable.Dispose();
             }
         }
         bonus.Entity.AddComponent(new BonusParachuteInstanceComponent(gameObject));
         gameObject.CollectComponentsInChildren(bonus.Entity);
         bonus.Entity.AddComponent <BonusSpawnStateComponent>();
         gameObject.SetActive(true);
     }
 }
Ejemplo n.º 5
0
        private void DrawEffect(GraffitiVisualEffect prefab, float length, Transform parent, string spriteUid, ItemRarityType rarity)
        {
            GetInstanceFromPoolEvent eventInstance = new GetInstanceFromPoolEvent {
                Prefab          = prefab.gameObject,
                AutoRecycleTime = length
            };

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

            instance.parent        = parent;
            instance.localPosition = Vector3.zero;
            instance.localRotation = Quaternion.identity;
            GraffitiVisualEffect component = instance.GetComponent <GraffitiVisualEffect>();

            component.Image.SpriteUid = spriteUid;
            component.Rarity          = rarity;
            component.gameObject.SetActive(true);
        }
Ejemplo n.º 6
0
        private void DrawShotTrailEffect(Vector3 shotPosition, Vector3 hitPosition, GameObject prefab, GameObject tipPrefab)
        {
            GetInstanceFromPoolEvent eventInstance = new GetInstanceFromPoolEvent {
                Prefab          = tipPrefab,
                AutoRecycleTime = tipPrefab.GetComponent <LineRendererEffectBehaviour>().duration
            };

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

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

            gameObject.SetActive(true);
            base.ScheduleEvent(eventInstance, new EntityStub());
            GameObject obj3 = eventInstance.Instance.gameObject;
            LineRendererEffectBehaviour behaviour2 = obj3.GetComponent <LineRendererEffectBehaviour>();

            obj3.SetActive(true);
            Vector3 vector    = hitPosition - shotPosition;
            float   magnitude = vector.magnitude;

            vector /= magnitude;
            if (magnitude <= 5f)
            {
                Vector3 vector5 = Vector3.Lerp(shotPosition, hitPosition, 0.5f);
                behaviour2.invertAlpha = true;
                Vector3[] vertices = new Vector3[] { shotPosition, vector5 };
                behaviour2.Init(component.LastScale, vertices);
                Vector3[] vectorArray5 = new Vector3[] { vector5, hitPosition };
                component.Init(behaviour2.LastScale, vectorArray5);
            }
            else
            {
                eventInstance.Prefab          = prefab;
                eventInstance.AutoRecycleTime = prefab.GetComponent <LineRendererEffectBehaviour>().duration;
                base.ScheduleEvent(eventInstance, new EntityStub());
                GameObject obj4 = eventInstance.Instance.gameObject;
                LineRendererEffectBehaviour behaviour3 = obj4.GetComponent <LineRendererEffectBehaviour>();
                obj4.SetActive(true);
                Vector3 vector2 = vector * 2.5f;
                Vector3 vector3 = shotPosition + vector2;
                Vector3 vector4 = hitPosition - vector2;
                behaviour2.invertAlpha = true;
                Vector3[] vertices = new Vector3[] { shotPosition, vector3 };
                behaviour2.Init(component.LastScale, vertices);
                Vector3[] vectorArray2 = new Vector3[] { vector3, vector4 };
                behaviour3.Init(behaviour2.LastScale, vectorArray2);
                int index = 0;
                while (true)
                {
                    if (index >= behaviour2.LastScale.Length)
                    {
                        Vector3[] vectorArray3 = new Vector3[] { vector4, hitPosition };
                        component.Init(behaviour2.LastScale, vectorArray3);
                        break;
                    }
                    behaviour2.LastScale[index] += behaviour3.LastScale[index];
                    index++;
                }
            }
        }