protected override void OnSimObjectUpdating(SimObject simObject, SimModel simModel, SimState simState) { if (Prey != null && (!CanBeVictim(Prey) || simObject.Location.GetDistance(Prey.Location) > ViewDistance)) { if (CanBeVictim(Prey)) { Prey.Color = Colors.Black; } Prey = null; GiveRandomDirection(simObject, simObject.Velocity.VectorMagnitude()); } if (Prey == null) { Prey = GetObjectsInView(simModel, simObject) .Where(CanBeVictim) .FirstOrDefault(); } if (Prey != null) { Prey.Color = Colors.Green; SetDestination(Prey.Location, simObject); var energy = simObject.GetProperty <EnergyProperty>(); if (energy != null && energy.Energy > 15) { UpdateSpeed(RunSpeed, simObject); } } }
protected override void OnSimObjectUpdating(SimObject simObject, SimModel simModel, SimState simState) { var nectarProp = simObject.GetProperty <NectarProperty>(); if (nectarProp == null) { nectarProp = new NectarProperty(); simObject.Properties.Add(nectarProp); } nectarProp.FillNectar(); }
protected override void OnSimObjectUpdating(SimObject simObject, SimModel simModel, SimState simState) { var energy = simObject.GetProperty <EnergyProperty>(); if (energy == null) { return; } var nectar = simObject.GetProperty <NectarProperty>(); if (nectar == null || !nectar.HasNectar) { energy.AddEnergy(1 * simState.MillisecondsSinceLastUpdate / 1000.0); } else { var magnitude = simObject.Velocity.VectorMagnitude(); energy.UseEnergy(magnitude * simState.MillisecondsSinceLastUpdate / 1000.0); } }
protected override void OnSimObjectCollision(SimObject sender, SimModel simModel, SimState simState, List <SimObject> collidingObjects) { var myNectar = sender.GetProperty <NectarProperty>(); if (myNectar != null && !myNectar.HasNectar) { foreach (var collidingObject in collidingObjects) { var theirNectar = collidingObject.GetProperty <NectarProperty>(); if (myNectar.GetNectarFrom(theirNectar)) { return; } } } }
protected override void OnSimObjectCollision(SimObject sender, SimModel simModel, SimState simState, List <SimObject> collidingObjects) { foreach (var collidingObject in collidingObjects) { foreach (var behaviour in collidingObject.Behaviours.ToList()) { if (!(behaviour is ZombieBehaviour)) { collidingObject.Behaviours.Remove(behaviour); collidingObject.Behaviours.Add(new ZombieBehaviour(Random)); Prey = null; var energyProp = sender.GetProperty <EnergyProperty>(); energyProp.AddEnergy(10); } } } GiveRandomDirection((Actor)sender, Speed); }