Exemplo n.º 1
0
 public void DisplayHardpoint(Hardpoint hardpoint)
 {
     if (hardpoint.isOccupied) {
         Attachment a = hardpoint.GetAttachment ();
         if (a != null) {
             this.DisplayAttachment (a);
         }
     } else {
         switch (hardpoint.attachmentRestriction) {
         case BlueprintType.CAB:
             nameText.text = "Crew Cabin Slot";
             break;
         default:
             nameText.text = "Hardpoint";
             break;
         }
         if (hardpoint.isInternal) {
             midText.text = "Internal Hardpoint";
         } else {
             midText.text = "External Hardpoint";
         }
     }
 }
Exemplo n.º 2
0
 private void PlaceAttachment(GameObject attachment, Hardpoint hardpoint)
 {
     Dictionary<ResourceType, int> price;
     Attachment a = attachment.GetComponent<Attachment> ();
     if (a.GetAttachmentType () != hardpoint.attachmentRestriction && hardpoint.attachmentRestriction != BlueprintType.None) { //if they don't match types and it has a restriction other than none
         Debug.LogWarning("Mismatched attachment type");
     } else if (hardpoint.isOccupied) {//remove the cost of the old attachment
         GameObject oldattachment = hardpoint.GetAttachment().gameObject;
         price = oldattachment.GetComponent<Attachment>().GetCost();
         foreach (ResourceType r in price.Keys) { //readd the cost of the now removed attachment
             costDisplay.UpdateResource(r, price[r]);
         }
         Destroy(oldattachment); //now that we've removed the cost, delete it
     }
     hardpoint.AddAttachment (attachment);
     holdingAttachment = false;
     Attachment na = attachment.GetComponent<Attachment> ();
     price = na.GetCost ();
     foreach (ResourceType r in price.Keys) { //subtract the cost of the new attachment
         costDisplay.UpdateResource(r, -price[r]); //notice how it's negative!
     }
 }