// helper function for incrementDay private void initMail(int storyID) { // update daysBeforeDeliver daysBeforeDeliver[storyID] = -1; // update latestMailWaiting latestMailWaiting[storyID]++; // actually init the mail string currMailID = getMailIDString(storyID, latestMailWaiting[storyID]); Mail currMail = mailDb.getMailByID(currMailID); Debug.Log(currMail.getFromHouseID()); House currHouse = houseDb.getHouseByID(currMail.getFromHouseID()); currHouse.addMail(currMailID); }
// returns house response // TODO: add interesting responses per house bool deliverMail(string mailID, string houseID) { // check for valid mailID and houseID if (!mailDb.isValidMail(mailID) || !mailBeingHeld.Contains(mailID)) { throw new System.Exception("Dashboard: deliverMail() - invalid mailID"); } Mail mail = mailDb.getMailByID(mailID); if (!houseDb.isValidHouse(houseID)) { throw new System.Exception("Dashboard: deliverMail() - invalid houseID"); } // check mail belongs to this house if (mail.getToHouseID() != houseID) { if (DASHBOARD_DEBUG) { Debug.Log("Dashboard: mail with ID " + mailID + " does not belong to house " + houseID); } return(false); // real code here } else { mail.setDelivered(); mailBeingHeld.Remove(mailID); deliveryCount++; timeKeeper.logMailDelivered(mailID); if (DASHBOARD_DEBUG) { Debug.Log("Dashboard: delivered mail with ID " + mailID + " to house " + houseID); } if (mailHeldChanged != null) { mailHeldChanged(mailBeingHeld); } return(true); } }
void makeMail(string mailId) { GameObject mailObject; if (mailPool.TryGetNextObject(Vector3.zero, Quaternion.identity, out mailObject)) { MailController mailController = mailObject.GetComponent <MailController>(); mailController.Init(mailDb.getMailByID(mailId)); usedMails.Add(mailController); } }