示例#1
0
        // Start is called before the first frame update
        private void Start()
        {
            DefaultWorldInitialization.Initialize("SwarmOfIron", false);

            World w = World.DefaultGameObjectInjectionWorld;

            //Init entityManager
            entityManager      = w.EntityManager;
            updateMoveToSystem = w.GetOrCreateSystem <UpdateMoveToSystem>();

            //create selection Mesh
            unitSelectedCircleMesh = SelectionMesh.CreateMesh(1.0f, 1.0f);

            //spawn some woods
            // Wood.SpawnWood(spawnWoodAmount);
            CustomEntity.SpawnEntitiesAtRandomPosition(typeof(Wood), spawnWoodAmount);
            CustomEntity.SpawnEntitiesAtRandomPosition(typeof(Rock), spawnRockAmount);

            //spawn some workers
            CustomEntity.SpawnEntitiesAtRandomPosition(typeof(Worker), spawnWorkerAmount);


            //spawn some soldiers
            Soldier.init();
            CustomEntity.SpawnEntitiesAtRandomPosition(typeof(Soldier), spawnSoldierAmount);
            //spawn Enemie soldiers
            E_Soldier.init();
            CustomEntity.SpawnEntitiesAtRandomPosition(typeof(E_Soldier), EspawnSoldierAmount);

            MiniMap.SpawnMiniMap();

            //CityHall.SpawnCityHall(new float3(0.0f, 0.0f, 0.0f));
        }
示例#2
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));
         }
     });
 }
示例#3
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());
         }
     }
 }
示例#4
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();
        }