public static AntViewController Create(AntSimulation.Ant a) { // This loads a default Ant view prefab Object prefab = Resources.Load("AntSimPrefabs/AntView"); if (prefab == null) { Debug.LogError("Please move the AntSimPrefabs directory to the Assets/Resources directory for prefabs to work"); } GameObject view = (GameObject)Instantiate(prefab); AntViewController viewController = view.GetComponent <AntViewController>(); // Associates the core Ant model with this ViewController viewController.model = a; viewController.sprite = view.GetComponent <UISprite>(); if (viewController.model.IsQueen()) { // Replace the current sprite with the appropriate name viewController.sprite.spriteName = "QueenToWestFromEast"; } viewController.sprite.MakePixelPerfect(); view.transform.parent = AntSimulation.singleton.colonyView.transform; view.transform.localPosition = startPos; view.transform.localScale = startScale; a.viewController = viewController; return(viewController); }
private void ChangeAnt(Ant ant) { this.ant = ant; Text = "Viewing the life of: " + ant.Name; txtAntHistory.Clear(); cachedList.Clear(); CheckHistory(); }
public void OnClick() { if (label.CompareTo("Cancel") == 0) { Debug.Log("Cancel!"); AntSimulation.singleton.HideButtons(); } else if (label.CompareTo("DNA Profile") == 0) { Debug.Log("DNA Profile!"); AntSimulation.Ant a = AntSimulation.singleton.lastSelectedAnt; string profile = ""; profile += System.Environment.NewLine + "Name: " + a.name; profile += System.Environment.NewLine + "Strength: " + a.dna.strength; profile += System.Environment.NewLine + "Intelligence: " + a.dna.intelligence; profile += System.Environment.NewLine + "Speed: " + a.dna.speed; profile += System.Environment.NewLine + "Attraction: " + a.dna.attraction; if (a.IsQueen()) { profile += System.Environment.NewLine + System.Environment.NewLine + "Seed DNA: "; if (a.seedDna != null) { profile += System.Environment.NewLine + "Strength: " + a.seedDna.strength; profile += System.Environment.NewLine + "Intelligence: " + a.seedDna.intelligence; profile += System.Environment.NewLine + "Speed: " + a.seedDna.speed; profile += System.Environment.NewLine + "Attraction: " + a.seedDna.attraction; profile += System.Environment.NewLine + "Eggs Left: " + a.eggs; } else { profile += "none"; } } AntSimulation.singleton.ShowModal("DNA Profile", profile); } else if (label.CompareTo("Modal") == 0) { Debug.Log("Modal"); AntSimulation.singleton.HideModal(); } else if (label.CompareTo("Nuptial Flight") == 0) { Debug.Log("Nuptial Flight!"); AntSimulation.singleton.ShowModal("Nuptial Flight", "All deez hoes"); StartCoroutine(AntSimulation.singleton.lastSelectedAnt.NuptialFlight()); } }
/// <summary> /// Class constructor of the form /// </summary> /// <param name="antFarm">the list of ants to cycle through</param> public FrmAntJournal(List<Ant> antFarm) { InitializeComponent(); antSelector.Maximum = antFarm.Count; cachedList = new List<string>(); ant = antFarm[0]; this.antFarm = antFarm; Text = "Viewing the life of: " + ant.Name; foreach (string lifeEvent in ant.LifeHistory) { txtAntHistory.Text += lifeEvent + Environment.NewLine; txtAntHistory.SelectionStart = txtAntHistory.Text.Length; txtAntHistory.ScrollToCaret(); cachedList.Add(lifeEvent); } }
//UpdateTimer cada 1 mls //Food Spawner cada 30,000 mls private void InitializeWorld() { Nest nest = new Nest(); nest.Position = world.Center; world.Add(nest); for (int i = 0; i < 75; i++)//Creo las 75 Hormigas con su position y rotation random { Ant ant = new Ant(nest); ant.Rotation = world.Random() * Math.PI * 2; ant.Position = nest.Position; world.Add(ant); } SpawnSomeFood(); }
public void DrawAnt(Ant ant, Graphics gfx) { Bitmap rotatedBitmap = GetBitmapForAnt(ant); if (ant.Facing == Direction.UpRight) rotatedBitmap = RotateImage(GetBitmapForAnt(ant), 45); else if (ant.Facing == Direction.Right) rotatedBitmap = RotateImage(GetBitmapForAnt(ant), 90); else if (ant.Facing == Direction.DownRight) rotatedBitmap = RotateImage(GetBitmapForAnt(ant), 135); else if (ant.Facing == Direction.Down) rotatedBitmap = RotateImage(GetBitmapForAnt(ant), 180); else if (ant.Facing == Direction.DownLeft) rotatedBitmap = RotateImage(GetBitmapForAnt(ant), 225); else if (ant.Facing == Direction.Left) rotatedBitmap = RotateImage(GetBitmapForAnt(ant), 270); else if (ant.Facing == Direction.UpLeft) rotatedBitmap = RotateImage(GetBitmapForAnt(ant), 315); gfx.DrawImage(rotatedBitmap, new Rectangle(ant.Location, ant.Size)); }
public Bitmap GetBitmapForAnt(Ant ant) { if (ant.HasFood) return bmpAntCarryingFood[(int)ant.Family]; else return bmpAnt[(int)ant.Family]; }
private bool HasSameFamily(Ant ant) { if (ant.Family == this.Family) return true; else return false; }
public void Add(Ant obj)//Añada un objeto al mundo { Hormigas.Add(obj); }