private static ParticleSystem.Particle PheroToParticle(PheromoneModel phero) { ParticleSystem.Particle p = new ParticleSystem.Particle { startSize = 0.3f, remainingLifetime = 5, position = phero.Position, startColor = new Color(1f, 1f, 1f, 0.5f) }; return(p); }
public static PheroStruct FromModel(PheromoneModel model) { return(new PheroStruct { HomeDistance = model.HomeDistance, FoodDistance = model.FoodDistance, position = model.Position, Strength = model.Strength, Confusion = model.Confusion, SpecialType = AssignSpecial(model), }); }
private static int AssignSpecial(PheromoneModel model) { if (model.IsAttract) { return(2); } if (model.IsRepellant) { return(1); } return(0); }
public void writeDebugInfo(Text debugInfo, bool renderBlocked, GameState gameState) { Vector3 pz = Camera.main.ScreenToWorldPoint(Input.mousePosition); PheromoneModel near = GameState.Search <PheromoneModel> .Nearest(gameState.findPheromonesInRange(pz, 0.3f), pz); string pheroInfo = near == null ? " -- " : "confusion " + near.Confusion.ToString("0.00") + ", homeDist " + Mathf.Min(near.HomeDistance, 99.99f).ToString("00.00") + ", foodDist " + Mathf.Min(near.FoodDistance, 99.99f).ToString("00.00") + "\n"; frameTimeBuffer[frameTimeIndex] = calculateFrameInfo(renderBlocked); frameTimeIndex = (frameTimeIndex + 1) % BUFFER_FRAMES; BufferInfo info = CalculateBufferStats(); debugInfo.text = "FPS avr " + info.AverageFramerate.ToString("00.00") + ", min " + info.LowestFramerate.ToString("00.00") + " thread finished "+ (info.RenderIdleTime * 100).ToString("00.") + "%\n" + "Pheromones:" + gameState.Pheromones.AsList().Count + "\n" + "@" + pz.x.ToString("00.0") + "," + pz.y.ToString("00.0") + ": " + pheroInfo + "\n"; }
internal static float HomeOrFood(PheromoneModel model) { return(Mathf.Max(HomeDistance(model), FoodDistance(model))); }
internal static float FoodDistance(PheromoneModel model) { return(-model.FoodDistance); }
internal static float HomeDistance(PheromoneModel model) { return(-model.HomeDistance); }