public static void SpawnNpcsAroundPosition(Snapshot snapshot, Coordinates position, uint team, float edgeLength) { float totalNpcs = SimulationSettings.HQStartingTRexCount + SimulationSettings.HQStartingBrachioCount; for (int i = 0; i < totalNpcs; i++) { Vector3 offset = new Vector3(Random.Range(-edgeLength / 2, edgeLength / 2), 0, Random.Range(-edgeLength / 2, edgeLength / 2)); Coordinates coordinates = (position.ToVector3() + offset).ToCoordinates(); EntityTemplate entity = null; if (i < SimulationSettings.HQStartingBrachioCount) { entity = EntityTemplateFactory.CreateDinoBrachioTemplate(coordinates, team, 70); // 成年恐龙 } else { entity = EntityTemplateFactory.CreateDinoTRexTemplate(coordinates, team, 70); // 成年恐龙 } if (entity != null) { snapshot.AddEntity(entity); } } Debug.Log("Snapshot Dinosaurs generated ! count<" + totalNpcs + ">"); }
public void HatchOut() { EntityTemplate exampleEntity = null; switch (_eggType) { case EggTypeEnum.Brachiosaurus: exampleEntity = EntityTemplateFactory.CreateDinoBrachioTemplate(transform.position.ToCoordinates(), egg.Data.OwnerTokenId, 0); // 0岁小恐龙 break; case EggTypeEnum.TRex: exampleEntity = EntityTemplateFactory.CreateDinoTRexTemplate(transform.position.ToCoordinates(), egg.Data.OwnerTokenId, 0); // 0岁小恐龙 break; } if (exampleEntity != null) { var request1 = new WorldCommands.CreateEntity.Request(exampleEntity); worldCommandSender.SendCreateEntityCommand(request1, OnCreateDinoResponse); //Debug.Log("EggBehaviour HatchOut! Type:"+_eggType); } }