Example #1
0
 void PlaceTurret(Vector2 pos_)
 {
     if (money >= availableTurrets[turretIndex].IntProperty("price"))
     {
         bool canPlace = false;
         foreach (FRectangle r in gameMap.buildableAreas)
         {
             if (r.Contains(scenes.GetScene("game").ToVirtualPos(scenes.GetScene("td").ToVirtualPos(mouseMan.ClickPos()))))
             {
                 canPlace = true;
             }
         }
         foreach (Entity t in EntityCollection.GetGroup("turrets"))
         {
             if ((t.pos - scenes.GetScene("game").ToVirtualPos(scenes.GetScene("td").ToVirtualPos(mouseMan.ClickPos()))).Length() < 15)
             {
                 canPlace = false;
             }
         }
         foreach (Entity t in EntityCollection.GetGroup("rocks"))
         {
             if ((t.pos - scenes.GetScene("game").ToVirtualPos(scenes.GetScene("td").ToVirtualPos(mouseMan.ClickPos()))).Length() < 5)
             {
                 canPlace = false;
             }
         }
         if (canPlace)
         {
             money -= availableTurrets[turretIndex].IntProperty("price");
             Assembler.GetEnt(ElementCollection.GetEntRef(availableTurrets[turretIndex].Name), pos_, Content, ebuilder);
         }
     }
 }