public static void SpawnNpcsAroundPosition(SnapshotBuilder snapshot, Coordinates position, uint team)
        {
            float totalNpcs    = SimulationSettings.HQStartingWizardsCount + SimulationSettings.HQStartingLumberjacksCount;
            float radiusFromHQ = SimulationSettings.NPCSpawnDistanceToHQ;

            for (int i = 0; i < totalNpcs; i++)
            {
                float   radians = (i / totalNpcs) * 2 * Mathf.PI;
                Vector3 offset  = new Vector3(Mathf.Cos(radians), 0, Mathf.Sin(radians));
                offset *= radiusFromHQ;
                Coordinates coordinates = (position.ToVector3() + offset).ToCoordinates();

                Entity entity = null;
                if (i < SimulationSettings.HQStartingLumberjacksCount)
                {
                    entity = EntityTemplateFactory.CreateNPCLumberjackTemplate(coordinates, team);
                }
                else
                {
                    entity = EntityTemplateFactory.CreateNPCWizardTemplate(coordinates, team);
                }

                var id = snapshot.GenerateId();
                snapshot.Add(id, entity);
            }
        }
        private void SpawnWizard(Coordinates position)
        {
            var wizardCount   = GetWizardCount();
            int maxNpcWizards = 0;

            if (SpatialOS.Connection.GetWorkerFlag("max_npc_wizards").HasValue)
            {
                maxNpcWizards = int.Parse(SpatialOS.Connection.GetWorkerFlag(maxWizardsFlagName).Value);
            }
            if (wizardCount >= maxNpcWizards)
            {
                return;
            }
            var template = EntityTemplateFactory.CreateNPCWizardTemplate(position, teamAssignment.Data.teamId);

            SpatialOS.Commands.CreateEntity(npcSpawner, template);
        }
Ejemplo n.º 3
0
        private void SpawnWizard(Coordinates position)
        {
            var template = EntityTemplateFactory.CreateNPCWizardTemplate(position, teamAssignment.Data.teamId);

            SpatialOS.Commands.CreateEntity(npcSpawner, SimulationSettings.NPCWizardPrefabName, template, result => { });
        }