//RYSOWANIE NA EKRANIE public void Draw() { Globals.spriteBatch.Begin(); Globals.spriteBatch.Draw(Globals.backgroundTexture, new Vector2(0, 0), Color.White); foreach (IEntity entity in DrawList) { entity.Draw(); } List <ChildrenFly> ListOfChildrenFlies = ((Hive)DrawList.Find(x => x is Hive)).ChildrenFlies; Globals.spriteBatch.Draw(Globals.hpBar, new Rectangle(30, 2, 100, 22), new Color(0, 0, 0, 150)); Globals.spriteBatch.DrawString(Globals.defaultFont, "My Hive: " + ListOfChildrenFlies.Count.ToString(), new Vector2(36, 4), Color.White); Globals.spriteBatch.End(); }
/// <summary> /// delete draw objcet /// </summary> /// <param name="drawObject"></param> public void DeleteDrawObject(DrawObject drawObject) { var removeItem = graphicsList.Find(item => item.Name == drawObject.Name); var success = graphicsList.Remove(removeItem); }
//OBLICZENIA public void Update() { Globals.newKeyState = Keyboard.GetState(); if (!isLoaded) { OnLoad(); isLoaded = true; } if (KeypressTest(Keys.Escape)) { Globals.activeState = Globals.enGameStates.PAUSE; } for (int i = 0; i < UpdateList.Count(); i++) { UpdateList[i].Update(); } Draw(); if (getCountOfChildrenFlies() == 0) { ResetState(); Globals.winner = "SPIDER!"; } else if (getCountOfChildrenFlies() > 150) { ResetState(); Globals.winner = "BUTTERFLY!"; } //FLOWER if (!IfDrawListHasFlower()) { counter2 = 0; if (counter1 < 60 * 3) { counter1++; } else { DrawList.Insert(20, new Flower(this, GenerateNewPositionForFlower())); } } else { counter1 = 0; if (counter2 < 60 * 8) { counter2++; } else { counter2 = 0; DrawList.Remove(DrawList.Find(x => x is Flower)); DrawList.Insert(20, new Flower(this, GenerateNewPositionForFlower())); } } Globals.oldKeyState = Globals.newKeyState; }
int getCountOfChildrenFlies() { List <ChildrenFly> ListOfChildrenFlies = ((Hive)DrawList.Find(x => x is Hive)).ChildrenFlies; return(ListOfChildrenFlies.Count); }
private bool IfDrawListHasFlower() { return(DrawList.Find(x => x is Flower) != null); }