public static Entity Instantiate(EntityCommandBuffer.Concurrent ecb,
                                         int jobIndex,
                                         float3 target,
                                         Entity prefab,
                                         Entity prefabTrail,
                                         float3 pos,
                                         float3 vel,
                                         float time)
        {
            var entity = ecb.Instantiate(jobIndex, prefab);

            ecb.SetComponent(jobIndex, entity, new Translation {
                Value = pos,
            });
            var rot = quaternion.LookRotationSafe(vel, new float3(0, 1, 0));

            ecb.SetComponent(jobIndex, entity, new Rotation {
                Value = rot,
            });
            ecb.SetComponent(jobIndex, entity, new MissileComponent {
                Target = target, Velocity = vel,
            });
            ecb.SetComponent(jobIndex, entity, AlivePeriod.Create(time, 2f /* period */));
            TrailSystem.Instantiate(ecb, jobIndex, prefabTrail, entity /* refering_entity */, pos, 0.5f /* width */, new Color(0.8f, 0.8f, 0.8f), time);
            return(entity);
        }
Exemplo n.º 2
0
 public void StartParticlesWithBurst()
 {
     setMainPrewarm(false);
     MainSystem.Play();
     BurstSystem.Play();
     TrailSystem.Play();
 }
Exemplo n.º 3
0
        private void Awake()
        {
            _iniProjectileSpeed         = ProjectileSpeed;
            _menuManager                = FindObjectOfType <MenuManager>();
            _menuManager.OnStartGame   += StartGame;
            _menuManager.OnRestartGame += RestartGame;

            _gridSystem = FindObjectOfType <GridSystem>();

            _infGrid = (InfiniteHexGrid)_gridSystem.Grid;

            _metronome       = _gridSystem.GetComponent <Metronome>();
            _metronome.Beat += Shoot;

            _trail = _gridSystem.GetComponent <TrailSystem>();

            _position = transform.position;

            _player = FindObjectOfType <Player>();

            var go = Resources.Load <GameObject>("Boss/Projectile");

            _obstacleMask = LayerMask.GetMask("Player");

            _projectiles = new Transform[ProjectilesCount];

            for (int i = 0; i < ProjectilesCount; i++)
            {
                _projectiles[i]          = Instantiate(go).transform;
                _projectiles[i].position = Vector3.one * -1000;
            }

            _lastTime = _metronome.ElapsedTime;
            Hp        = MaxHp;
        }
Exemplo n.º 4
0
        private void Awake()
        {
            _coins = new GameObject[CoinPool * _mul];

            var go = Resources.Load <GameObject>("Pool/Coin");

            _menuManager = FindObjectOfType <MenuManager>();
            _menuManager.OnRestartGame += RestartGame;

            for (int i = 0; i < CoinPool * _mul; i++)
            {
                _coins[i] = Instantiate(go);
                _coins[i].transform.position = Vector3.one * -1000;
            }

            _trail = FindObjectOfType <TrailSystem>();

            if (_gridSystem == null)
            {
                _gridSystem = GetComponent <GridSystem>();
            }

            _infGrid         = (InfiniteHexGrid)_gridSystem.Grid;
            _metronome       = FindObjectOfType <Metronome>();
            _metronome.Beat += PopCoin;

            _infGrid = (InfiniteHexGrid)_gridSystem.Grid;
        }
Exemplo n.º 5
0
        private void Awake()
        {
            _pool = new GameObject[PoolSize * _mul];

            _obstacles = Resources.LoadAll <GameObject>("Pool/Obstacles");

            _menuManager = FindObjectOfType <MenuManager>();
            _menuManager.OnRestartGame += RestartGame;

            for (int i = 0; i < PoolSize * _mul; i++)
            {
                _pool[i] = Instantiate(_obstacles[i % _obstacles.Length]);
                _pool[i].transform.position = Vector3.one * -1000;
            }

            _trail = FindObjectOfType <TrailSystem>();

            if (_gridSystem == null)
            {
                _gridSystem = GetComponent <GridSystem>();
            }

            _infGrid   = (InfiniteHexGrid)_gridSystem.Grid;
            _metronome = FindObjectOfType <Metronome>();

            _infGrid = (InfiniteHexGrid)_gridSystem.Grid;
        }
Exemplo n.º 6
0
        private void Awake()
        {
            _self = (TrailSystem)target;

            if (_self.GridSystem == null)
            {
                _self.GridSystem = _self.GetComponent <GridSystem>();
            }
        }
Exemplo n.º 7
0
        public static void RunColony(TrailSystem <TravelToCity> system, Func <Ant <TravelToCity> > createAnt)
        {
            var result = AntColony.OptimizeCSharp(createAnt,
                                                  50, 50, system);

            foreach (var x in result)
            {
                Console.WriteLine(x.Destination.Name);
            }
        }
        public static Entity Instantiate(Entity prefab, float3 pos, quaternion rot)
        {
            var em     = World.DefaultGameObjectInjectionWorld.EntityManager;
            var entity = em.Instantiate(prefab);

#if UNITY_EDITOR
            em.SetName(entity, "missile");
#endif
            em.SetComponentData(entity, new Translation {
                Value = pos,
            });
            em.SetComponentData(entity, new Rotation {
                Value = rot,
            });
            em.SetComponentData(entity, new MissileComponent {
                Target = new float3(0, 0, 0),
            });
            em.SetComponentData(entity, AlivePeriod.Create(UTJ.Time.GetCurrent(), 2f /* period */));
            TrailSystem.Instantiate(entity, pos, 0.5f /* width */, Color.white,
                                    new float3(0f, 0f, -0.5f) /* offset */, 4f / 60f /* update_interval */);
            return(entity);
        }
 private void Start()
 {
     rb = GetComponent <Rigidbody>();
     TS = GetComponent <TrailSystem>();
 }
Exemplo n.º 10
0
 void Awake()
 {
     trailSys = new TrailSystem();
 }
Exemplo n.º 11
0
 public void StopParticles()
 {
     MainSystem.Stop();
     TrailSystem.Stop();
 }
Exemplo n.º 12
0
 public void StartParticlesWithoutBurst()
 {
     setMainPrewarm(true);
     MainSystem.Play();
     TrailSystem.Play();
 }