/// <summary> /// Builds a new life form. /// </summary> /// <param name="lifeFormType">The life form type to build.</param> /// <returns>A newly instantiated life form object.</returns> public static LifeFormBase Build(LifeForm lifeFormType) { LifeFormBase lifeForm = null; switch (lifeFormType) { case LifeForm.Empty: lifeForm = new Empty(); break; case LifeForm.Acorn: lifeForm = new Acorn(); break; case LifeForm.AircraftCarrier: lifeForm = new AircraftCarrier(); break; case LifeForm.FivePoint: lifeForm = new FivePoint(); break; default: lifeForm = new RandomPattern( rows: RANDOMPATTERNHEIGHT, cols: RANDOMPATTERNWIDTH); break; } return(lifeForm); }
/// <summary> /// Builds a new life form. /// </summary> /// <param name="lifeFormType">The life form type to build.</param> /// <returns>A newly instantiated life form object.</returns> public static LifeFormBase Build(LifeForm lifeFormType) { LifeFormBase lifeForm = null; switch (lifeFormType) { case LifeForm.Empty: lifeForm = new Empty(); break; case LifeForm.Acorn: lifeForm = new Acorn(); break; case LifeForm.AircraftCarrier: lifeForm = new AircraftCarrier(); break; case LifeForm.FivePoint: lifeForm = new FivePoint(); break; default: lifeForm = new RandomPattern( rows: RANDOMPATTERNHEIGHT, cols: RANDOMPATTERNWIDTH); break; } return lifeForm; }
public void Mutate(SkillTypes aSkillType, Int32 aNewValue, LifeForm aLifeForm) { if ((aLifeForm.LfType == LifeFormTypes.MasterEntity) || (aLifeForm.LfType == LifeFormTypes.EnvironmentEntity)) { Mutate(aSkillType, aNewValue); } }
//LifeformDied callback private void OnLifeformDied(LifeForm lifeform) { LifeformsAliveCount--; if (LifeformsAliveCount == 0 && AllLifeformsDead != null) { AllLifeformsDead(); } }
void Start() { this.lifeForm = this.GetComponentInChildren <LifeForm>(); this.sr = this.GetComponentInChildren <SpriteRenderer>(); this.lifeForm.deathEvent += Die; ResetState(); }
public GameOfLife(int worldSize, Pattern lifePattern, int numOfGenerations, int consolePrintSleep) { var world = new World(worldSize) .SetPattern(lifePattern); life = new LifeForm(world); this.numOfGenerations = numOfGenerations; this.consolePrintSleep = consolePrintSleep; }
public override Task <Location> BeamDown(LifeForm request, ServerCallContext context) { // Uncomment to test the client deadline. // Task.Delay(60000).Wait(); return(Task.FromResult(new Location { Description = Data.Locations.WhereEver() })); }
void Start() { this.sr = this.GetComponent <SpriteRenderer>(); this.lifeForm = this.GetComponent <LifeForm>(); this.mapManager = MapManager.GetMapManager(); this.lifeForm.deathEvent += Die; StartCoroutine(Spread()); }
public override Task <LifeForm> BeamUp(Location request, ServerCallContext context) { var whoEver = Data.LifeForms.WhoEver(); var result = new LifeForm { Species = whoEver.Item1, Name = whoEver.Item2, Rank = whoEver.Item3 }; return(Task.FromResult(result)); }
public override void ManageMasterNotification(NotificationType aNotifyType, LifeForm aLifeForm) { switch (aNotifyType) { case Life.NotificationType.Born: if (!ManagedOnes.ContainsValue(aLifeForm)) ManagedOnes.Add(aLifeForm.dna.Id, aLifeForm); break; case Life.NotificationType.Dead: if (ManagedOnes.ContainsValue(aLifeForm)) ManagedOnes.Remove(aLifeForm.dna.Id); break; } }
private async void ReplaceParty_Click(object sender, RoutedEventArgs e) { // Creating a party. var rnd = _rnd.Next(2, 5); var lifeForms = new List <LifeForm>(); for (int i = 0; i < rnd; i++) { var whoEver = Data.LifeForms.WhoEver(); var lifeForm = new LifeForm { Species = whoEver.Item1, Name = whoEver.Item2, Rank = whoEver.Item3 }; lifeForms.Add(lifeForm); } WriteLog($"Replacing a party."); using (var call = _client.ReplaceParty()) { var responseReaderTask = Task.Run(async() => { while (await call.ResponseStream.MoveNext()) { var beamedDown = call.ResponseStream.Current; await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { WriteLog($"- Beamed down {beamedDown.Rank} {beamedDown.Name} ({beamedDown.Species})."); }); } }); foreach (var request in lifeForms) { await call.RequestStream.WriteAsync(request); WriteLog($"- Beamed up {request.Rank} {request.Name} ({request.Species})."); } ; await call.RequestStream.CompleteAsync(); await responseReaderTask; } WriteLog($"- Party replaced."); }
void Start() { this.cpu = this.GetComponent <CPU>(); this.rb = this.GetComponent <Rigidbody2D>(); this.sr = this.GetComponent <SpriteRenderer>(); this.lifeForm = this.GetComponent <LifeForm>(); this.toc = this.GetComponent <TriggerObservationCompiler>(); this.mapManager = MapManager.GetMapManager(); this.opm = ObjectPoolManager.GetObjectPoolManager(); this.lifeForm.deathEvent += Die; ResetState(); }
public override void Execute() { using (LifeForm frm = new LifeForm()) { frm.Viewer.Options.LS_LifeGame = fLangMan.LS(PLS.LSID_LifeGame); frm.Viewer.Options.LS_Step = fLangMan.LS(PLS.LSID_Step); frm.Viewer.Options.LS_Start = fLangMan.LS(PLS.LSID_Start); frm.Viewer.Options.LS_Stop = fLangMan.LS(PLS.LSID_Stop); frm.Viewer.Options.LS_SetCells = fLangMan.LS(PLS.LSID_SetCells); frm.Viewer.Options.LS_Clear = fLangMan.LS(PLS.LSID_Clear); frm.Viewer.Options.LS_Random = fLangMan.LS(PLS.LSID_Random); frm.Viewer.Options.LS_Options = fLangMan.LS(PLS.LSID_Options); frm.ShowDialog(); } }
private async void BeamDownOne_Click(object sender, RoutedEventArgs e) { var whoEver = Data.LifeForms.WhoEver(); var lifeForm = new LifeForm { Species = whoEver.Item1, Name = whoEver.Item2, Rank = whoEver.Item3 }; // var location = _client.BeamDown(lifeForm); // Uncomment the delay in the Service method to test the deadline. var location = await _client.BeamDownAsync(lifeForm, deadline : DateTime.UtcNow.AddSeconds(5)); WriteLog($"Beamed down {lifeForm.Rank} {lifeForm.Name} ({lifeForm.Species}) to {location.Description}."); }
void Reproduce() { LifeForm offspring = (LifeForm)Instantiate(this, GetOffspringPosition(), Quaternion.identity);//Todo Make an entity if (Random.Range(0f, 100f) < mutationChance) { //Spawn another LifeForm with a varied stat int rand = Random.Range(1, 7); switch (rand) { case 1: offspring.MutateReproductionRate(); break; case 2: offspring.MutateDeathRate(); break; case 3: offspring.MutateMutationChance(); break; case 4: offspring.MutateMoveSpeed(); break; case 5: offspring.MutateVision(); break; case 6: offspring.MutateSize(); break; case 7: offspring.MutateEatRange(); break; default: break; } offspring.MutateColor(); } WorldProperties.world.newBornQueue.Add(offspring); }
public override async Task BeamUpParty(Location request, IServerStreamWriter <LifeForm> responseStream, ServerCallContext context) { var rnd = _rnd.Next(2, 5); for (int i = 0; i < rnd; i++) { var whoEver = Data.LifeForms.WhoEver(); var result = new LifeForm { Species = whoEver.Item1, Name = whoEver.Item2, Rank = whoEver.Item3 }; await responseStream.WriteAsync(result); } }
public override void ManageMasterNotification(NotificationType aNotifyType, LifeForm aLifeForm) { switch (aNotifyType) { case Life.NotificationType.Born: if (!LivingOnes.ContainsValue(aLifeForm)) { LivingOnes.Add(aLifeForm.dna.Id, aLifeForm); } break; case Life.NotificationType.Dead: if (LivingOnes.ContainsValue(aLifeForm)) { LivingOnes.Remove(aLifeForm.dna.Id); DeadOnes.Add(aLifeForm.dna.Id, aLifeForm); } break; } }
private async void BeamDownParty_Click(object sender, RoutedEventArgs e) { var rnd = _rnd.Next(2, 5); var lifeForms = new List <LifeForm>(); for (int i = 0; i < rnd; i++) { var whoEver = Data.LifeForms.WhoEver(); var lifeForm = new LifeForm { Species = whoEver.Item1, Name = whoEver.Item2, Rank = whoEver.Item3 }; lifeForms.Add(lifeForm); } WriteLog($"Beaming down a party."); using (var call = _client.BeamDownParty()) { foreach (var lifeForm in lifeForms) { await call.RequestStream.WriteAsync(lifeForm); WriteLog($"- Beamed down {lifeForm.Rank} {lifeForm.Name} ({lifeForm.Species})."); } await call.RequestStream.CompleteAsync(); var location = await call.ResponseAsync; WriteLog($"- Party beamed down to {location.Description}."); } }
public FoodLifeForm(LifeForm aMaster) : base(aMaster, LifeFormTypes.FoodTypeLifeForm) { FoodValue = GetAttribute(SkillTypes.FoodProductionRate); BeginMainTask(); }
public EnvironmentLifeForm(LifeForm aMaster) : base(aMaster, LifeFormTypes.EnvironmentEntity) { BeginMainTask(); }
public EnvironmentLifeForm(LifeForm aMaster, LifeFormTypes aLifeFormType) : base(aMaster, aLifeFormType) { BeginMainTask(); }
public EnvironmentLifeForm(LifeForm aMaster, LifeFormTypes aLifeFormType, DNASequence aDna) : base(aMaster, aLifeFormType, aDna) { BeginMainTask(); }
public override void NotifyMasterLifeForm(NotificationType aNotifyType, LifeForm aLifeForm) { ManageMasterNotification(aNotifyType, aLifeForm); base.NotifyMasterLifeForm(aNotifyType, aLifeForm); }
public static GenerationSet NewField(LifeForm[] Olds) { return null; }
public FoodLifeForm(LifeForm aMaster, LifeFormTypes aLifeFormType, DNASequence aDna) : base(aMaster, aLifeFormType, aDna) { FoodValue = GetAttribute(SkillTypes.FoodProductionRate); BeginMainTask(); }