Advertisement
Guest User

Untitled

a guest
Feb 17th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.15 KB | None | 0 0
  1.  
  2. public bool BuildManaFountain(Elf elf)
  3. {
  4. int i = 2;
  5. bool right = Utility.game.GetMyCastle().GetLocation().Col > Utility.game.GetEnemyCastle().GetLocation().Col;
  6. bool up = Utility.game.GetMyCastle().GetLocation().Row <= Utility.game.Rows/2;
  7. if(Utility.manaCount < 3)
  8. {
  9. Location loc = Utility.game.GetMyCastle().GetLocation();
  10. int manaRadius = Utility.game.ManaFountainSize;
  11. Location manaFountain = new Location(up ? manaRadius : Utility.game.Rows - manaRadius, 0);
  12. manaFountain.Col = right ? loc.Col - Utility.game.CastleSize - manaRadius : loc.Col + manaRadius;
  13. int defCol = manaFountain.Col;
  14. int nextRow = manaFountain.Row;
  15.  
  16. i = 0;
  17. while(!Utility.game.CanBuildManaFountainAt(manaFountain) && Utility.game.InMap(manaFountain))
  18. {
  19. if(i % 2 == 0)
  20. {
  21. manaFountain.Col = defCol - i/2;
  22. manaFountain.Row = nextRow;
  23. nextRow += up ? manaRadius*2 : -manaRadius*2;
  24. }
  25. else
  26. {
  27. manaFountain.Col += right ? -manaRadius*2-1 : manaRadius*2+1;
  28. }
  29. i++;
  30. }
  31.  
  32. Utility.Log("Going to : " + manaFountain + ", i = " + i.ToString());
  33. if (elf.GetLocation().Equals(manaFountain))
  34. {
  35. if(elf.CanBuildManaFountain())
  36. {
  37. elf.BuildManaFountain();
  38. Utility.manaCount++;
  39. }
  40. else
  41. Utility.StorageMana = Utility.game.ManaFountainCost;
  42. Utility.portalLoc = manaFountain;
  43. }
  44. else if(Utility.game.InMap(manaFountain))
  45. elf.MoveTo(manaFountain);
  46. else return false;
  47. return true;
  48. }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement