Ejemplo n.º 1
0
 private void ApplyActionToButton(Button button, ActionValPair pair, List<Cost> costs, GameObject menu)
 {
     //apply appropriate action
     switch (pair.action) {
     case Toolbox.BasicAction.Add_Energy_Red:
         button.onClick.AddListener(() => {
             if (MeetsCosts(costs)){
                 player.AddEnergy(pair.val, Toolbox.EnergyColour.Red);
                 if(player.PayCosts(costs)){
                     player.DestroyCard(this);
                 } else {
                     player.DiscardCard(this);
                 }
                 Destroy(menu);
             }
         });
         break;
     case Toolbox.BasicAction.Add_Energy_Blue:
         button.onClick.AddListener(() => {
             if (MeetsCosts(costs)){
                 player.AddEnergy(pair.val, Toolbox.EnergyColour.Blue);
                 if(player.PayCosts(costs)){
                     player.DestroyCard(this);
                 } else {
                     player.DiscardCard(this);
                 }
                 Destroy(menu);
             }
         });
         break;
     case Toolbox.BasicAction.Add_Energy_White:
         button.onClick.AddListener(() => {
             if (MeetsCosts(costs)){
                 player.AddEnergy(pair.val, Toolbox.EnergyColour.White);
                 if(player.PayCosts(costs)){
                     player.DestroyCard(this);
                 } else {
                     player.DiscardCard(this);
                 }
                 Destroy(menu);
             }
         });
         break;
     case Toolbox.BasicAction.Add_Energy_Green:
         button.onClick.AddListener(() => {
             if (MeetsCosts(costs)){
                 player.AddEnergy(pair.val, Toolbox.EnergyColour.Green);
                 if(player.PayCosts(costs)){
                     player.DestroyCard(this);
                 } else {
                     player.DiscardCard(this);
                 }
                 Destroy(menu);
             }
         });
         break;
     case Toolbox.BasicAction.Add_Energy_Dark:
         button.onClick.AddListener(() => {
             if (MeetsCosts(costs)){
                 player.AddEnergy(pair.val, Toolbox.EnergyColour.Dark);
                 if(player.PayCosts(costs)){
                     player.DestroyCard(this);
                 } else {
                     player.DiscardCard(this);
                 }
                 Destroy(menu);
             }
         });
         break;
     case Toolbox.BasicAction.Source_Uses:
         button.onClick.AddListener(() => {
             if (MeetsCosts(costs)){
                 player.sourceUsesLeft += pair.val;
                 player.UpdateLabels();
                 if(player.PayCosts(costs)){
                     player.DestroyCard(this);
                 } else {
                     player.DiscardCard(this);
                 }
                 Destroy(menu);
             }
         });
         break;
     case Toolbox.BasicAction.Move:
         button.onClick.AddListener(() => {
             if (MeetsCosts(costs)){
                 player.moves += pair.val;
                 player.UpdateLabels();
                 if(player.PayCosts(costs)){
                     player.DestroyCard(this);
                 } else {
                     player.DiscardCard(this);
                 }
                 Destroy(menu);
             }
         });
         break;
     case Toolbox.BasicAction.Influence:
         button.onClick.AddListener(() => {
             if (MeetsCosts(costs)){
                 player.influence += pair.val;
                 player.UpdateLabels();
                 if(player.PayCosts(costs)){
                     player.DestroyCard(this);
                 } else {
                     player.DiscardCard(this);
                 }
                 Destroy(menu);
             }
         });
         break;
     case Toolbox.BasicAction.Heal:
         button.onClick.AddListener(() => {
             if (MeetsCosts(costs)){
                 player.DoHeal(pair.val);
                 if(player.PayCosts(costs)){
                     player.DestroyCard(this);
                 } else {
                     player.DiscardCard(this);
                 }
                 Destroy(menu);
             }
         });
         break;
     case Toolbox.BasicAction.Block:
         button.onClick.AddListener(() => {
             if (MeetsCosts(costs)){
                 player.AddBlock(pair.val, pair.attackColour);
                 if(player.PayCosts(costs)){
                     player.DestroyCard(this);
                 } else {
                     player.DiscardCard(this);
                 }
                 Destroy(menu);
             }
         });
         break;
     case Toolbox.BasicAction.Ranged_Attack:
     case Toolbox.BasicAction.Attack:
         button.onClick.AddListener(() => {
             if (MeetsCosts(costs)){
                 player.AddAttack(pair.val, pair.attackColour);
                 if(player.PayCosts(costs)){
                     player.DestroyCard(this);
                 } else {
                     player.DiscardCard(this);
                 }
                 Destroy(menu);
             }
         });
         break;
     default:
         break;
     }
 }
Ejemplo n.º 2
0
 public string ButtonString(ActionValPair pair)
 {
     string returnString = "";
     switch (pair.action){
     case Toolbox.BasicAction.Block:
     case Toolbox.BasicAction.Attack:
         returnString +=  pair.attackColour.ToString() + " " + pair.action.ToString() + " " +  pair.val.ToString();
         break;
     case Toolbox.BasicAction.Ranged_Attack:
         returnString += "Ranged " + pair.attackColour.ToString() + " Attack " + pair.val.ToString();
         break;
     case Toolbox.BasicAction.Add_Energy_Red:
         returnString += "Add " + pair.val.ToString() + " " + Toolbox.EnergyColour.Red.ToString() + " Energy";
         break;
     case Toolbox.BasicAction.Add_Energy_Blue:
         returnString += "Add " + pair.val.ToString() + " " + Toolbox.EnergyColour.Blue.ToString() + " Energy";
         break;
     case Toolbox.BasicAction.Add_Energy_Green:
         returnString += "Add " + pair.val.ToString() + " " + Toolbox.EnergyColour.Green.ToString() + " Energy";
         break;
     case Toolbox.BasicAction.Add_Energy_White:
         returnString += "Add " + pair.val.ToString() + " " + Toolbox.EnergyColour.White.ToString() + " Energy";
         break;
     case Toolbox.BasicAction.Add_Energy_Dark:
         returnString += "Add " + pair.val.ToString() + " " + Toolbox.EnergyColour.Dark.ToString() + " Energy";
         break;
     case Toolbox.BasicAction.Source_Uses:
         returnString += "Add " + pair.val.ToString() + " Source Uses";
         break;
     default:
         returnString += pair.action.ToString() + " " + pair.val.ToString();
         break;
     }
     return returnString;
 }