Ejemplo n.º 1
0
 public void spawWorkers()
 {
     Entities.WithAll <CityHallComponent>().ForEach((ref Translation translation, ref UnitSelectedComponent unitSelectedComponent) => {
         if (SwarmOfIron.Instance.goldAmount >= 10.0f)
         {
             SwarmOfIron.Instance.goldAmount -= 10.0f;
             CustomEntity.SpawnEntityAtPosition(typeof(Worker), translation.Value + new float3(0, 0, -20));
         }
     });
 }
Ejemplo n.º 2
0
 public void ExecuteCurrentAction(string action)
 {
     if (action == "ArrowIcon")
     {
         //move selected units
         SwarmOfIron.Instance.updateMoveToSystem.Update();
     }
     else if (action == "HouseIcon")
     {
         if (SwarmOfIron.Instance.goldAmount >= 100.0f)
         {
             SwarmOfIron.Instance.goldAmount -= 100.0f;
             CustomEntity.SpawnEntityAtPosition(typeof(CityHall), UnitControlHelpers.GetMousePosition());
         }
     }
 }
Ejemplo n.º 3
0
        protected override void OnUpdate()
        {
            NativeArray <Translation> AllEnemiPos = EnemiQuery.ToComponentDataArray <Translation>(Allocator.TempJob);
            NativeArray <Translation> AllUnitPos  = UnitQuery.ToComponentDataArray <Translation>(Allocator.TempJob);

            var job = new FindTarget()
            {
                U_positions         = AllUnitPos,
                entityCommandBuffer = endSimulationEntityCommandBufferSystem.CreateCommandBuffer().ToConcurrent(),
                //E_positions = AllEnemiPos
            };
            JobHandle dependency = job.Schedule(EnemiQuery);



            endSimulationEntityCommandBufferSystem.AddJobHandleForProducer(dependency);
            dependency.Complete();

            for (int i = 0; i < AllUnitPos.Length; i++)
            {
                for (int j = 0; j < AllEnemiPos.Length; j++)
                {
                    //   if (Time.DeltaTime > nextShootTime)
                    // {
                    if (math.distance(AllEnemiPos[j].Value, AllUnitPos[i].Value) < 18f)
                    {
                        CustomEntity.SpawnEntityAtPosition(typeof(Projectiles), AllEnemiPos[j].Value);
                        //float fireRate = .03f;
                        //nextShootTime = Time.DeltaTime + fireRate;
                    }
                    // }
                }
            }

            var job2 = new FindCible()
            {
                U_positions         = AllUnitPos,
                entityCommandBuffer = E_endSimulationEntityCommandBufferSystem.CreateCommandBuffer().ToConcurrent(),
            };
            JobHandle dependency2 = job2.Schedule(ProjectileQuery);

            E_endSimulationEntityCommandBufferSystem.AddJobHandleForProducer(dependency2);
            dependency2.Complete();
            AllUnitPos.Dispose(dependency2);
            AllEnemiPos.Dispose();
        }