예제 #1
0
    public bool Research(TechBranch br)
    {
        if (unlockedBranches == null)
        {
            ChatManager.Msg("UnlockedBranches=null", MessageType.Error);
            return(false);
        }
        if (!unlockedBranches.Contains(br.id))
        {
            if (br.costFaithPoints > 0 && GameManager.village.GetFaithPoints() < br.costFaithPoints)
            {
                ChatManager.Msg("Nicht genügend Glaubenspunkte " + GameManager.village.GetFaithPoints(), MessageType.Info);
                return(false);
            }
            if (br.costTechPoints > 0 && GameManager.village.GetTechPoints() < br.costTechPoints)
            {
                ChatManager.Msg("Nicht genügend Technologiepunkte " + GameManager.village.GetTechPoints(), MessageType.Info);
                return(false);
            }

            // take costs
            GameManager.village.ChangeFaithPoints(-br.costFaithPoints);
            GameManager.village.ChangeTechPoints(-br.costTechPoints);

            unlockedBranches.Add(br.id);
            ChatManager.Msg("Du hast " + br.name + " erforscht!", MessageType.News);

            switch (br.name)
            {
            case "Kornfeld 1":
                GameManager.UnlockJob(Job.Get("Bauer"));
                break;

            case "Jäger 1":
                GameManager.UnlockJob(Job.Get("Jäger"));
                break;

            case "Holzfäller 1":
                GameManager.UnlockJob(Job.Get("Holzfäller"));
                break;

            case "Steinmetz 1":
                GameManager.UnlockJob(Job.Get("Steinmetz"));
                break;

            case "Glauben":
                GameManager.UnlockBuilding(Building.Get("Opferstätte"));
                break;
            }
            UIManager.Instance.UpdateTechTree();
        }
        else
        {
            ChatManager.Msg("Bereits erforscht", MessageType.Info);
        }
        return(true);
    }
예제 #2
0
 public bool CheckResearchChildren(string name, TechBranch parent)
 {
     if (!IsUnlocked(parent.id))
     {
         return(false);
     }
     if (parent.name == name)
     {
         return(true);
     }
     foreach (TechBranch child in parent.children)
     {
         if (CheckResearchChildren(name, child))
         {
             return(true);
         }
     }
     return(false);
 }