Exemplo n.º 1
0
 void OnEnable()
 {
     Color.Initialize();
     SystemManagerSystem.Ignite();
     TimeSystem.Ignite();
     SpriteRendererSystem.Ignite();
     BulletSpawnSystem.Ignite();
     SparkSpawnSystem.Ignite();
     ExplosionSpawnSystem.Ignite();
     SightSpawnSystem.Ignite();
     GameManagerSystem.Ignite();
     LockTargetManager.Init();
 }
Exemplo n.º 2
0
        public void spawn(ref float3 position,
                          ref quaternion rotation,
                          ref RandomLocal random,
                          ref AtomicFloatResource float_resource)
        {
            var entity_manager = Unity.Entities.World.Active.GetOrCreateManager <Unity.Entities.EntityManager>();
            var entity         = entity_manager.CreateEntity(archetype_);

            entity_manager.SetComponentData(entity, new Position {
                Value = position,
            });
            entity_manager.SetComponentData(entity, new Rotation {
                Value = rotation,
            });
            entity_manager.SetComponentData(entity, new RigidbodyRotation(10f /* damper */));
            entity_manager.SetComponentData(entity, random.create());
            entity_manager.SetComponentData(entity, new SphereCollider {
                offset_position_ = new float3(0f, 0f, 0f),
                radius_          = 1f,
            });
            entity_manager.SetComponentData(entity, AlivePeriod.Create(Time.GetCurrent(), 6f /* period */));
            var enemy = Enemy.Create(ref float_resource);

            entity_manager.SetComponentData(entity, enemy);
            entity_manager.SetComponentData(entity, new Zako {
                target_position_ = new float3(random.range(-20f, 20f), random.range(-20f, 20f), 0f),
            });
            entity_manager.SetComponentData(entity, new MeshRenderBounds {
                Center = new float3(0f, 0f, 0f), Radius = 0.5f,
            });
            var renderer = new MeshInstanceRenderer {
                mesh           = mesh_,
                material       = material_,
                subMesh        = 0,
                castShadows    = UnityEngine.Rendering.ShadowCastingMode.On,
                receiveShadows = true,
            };

            entity_manager.SetSharedComponentData(entity, renderer);

            for (var i = 0; i < locktarget_list_.Length; ++i)
            {
                LockTargetManager.CreateEntity(entity_manager,
                                               locktarget_list_[i].localPosition,
                                               locktarget_list_[i].localRotation,
                                               ref enemy.life_,
                                               entity,
                                               ref random);
            }
        }