Beispiel #1
0
 public DeployementOrder(unitCreation u, SpecialUnit.stats s, float f)
 {
     Unit            = u;
     stat            = s;
     ExtraExperience = f;
     AdditionalCost  = new List <Goods>();
 }
Beispiel #2
0
    public void ProduceUnit(unitCreation c, Owner b, bool avoid = false)
    {
        var we = new DeployementOrder(c, deplToUse.stat, deplToUse.ExtraExperience);

        if (avoid)
        {
            we = new DeployementOrder(c, new SpecialUnit.stats(), 0);
        }

        if (!GameManager.DEBUG_GODMODE)
        {
            if (!HasEnoughRessource(we, b.Inventory))
            {
                if (b.IsPlayer)
                {
                    GameManager.ShowMessage("Not enough materials for unit!");
                }
                return;
            }
        }
        b.Pay(c.unit.gameObject.GetComponent <unit>().GoldCost + we.extraGold);
        foreach (var item in we.Unit.Costs)
        {
            we.AdditionalCost.Add(item);
        }
        b.Pay(we.AdditionalCost.ToArray());

        QUI.CreateNewIcon(we);
        UnitsToDeploy.Enqueue(we);
    }
Beispiel #3
0
    void Start()
    {
        panels = new GameObject[] { p_RacePanel, p_ClassPanel, p_AppearancePanel, p_NamePanel };
        for (int i = 0; i < panels.Length; i++)
        {
            panels[i].SetActive(false);
        }
        unitButtons   = new GameObject[numOfParty];
        unitsToCreate = new unitCreation[numOfParty];
        for (int i = 0; i < numOfParty; i++)
        {
            unitsToCreate[i] = gameObject.AddComponent <unitCreation>();
        }
        InstantiatePartyButtons();

        for (int i = 0; i < numOfParty; i++)
        {
            selectedUnit = unitsToCreate[i];
            foreach (GameObject units in unitButtons)
            {
                unitText           = units.GetComponentsInChildren <Text>();
                t_Name             = unitText[0];
                t_NickName         = unitText[1];
                t_RaceClass        = unitText[2];
                t_HealthMagic      = unitText[3];
                t_Name.text        = null;
                t_NickName.text    = null;
                t_RaceClass.text   = null;
                t_HealthMagic.text = null;
            }
        }
        SelectUnit(0);
    }
Beispiel #4
0
    public bool HasEnoughRessource(unitCreation x, Goods[] c)
    {
        if (GetOwner.Gold < x.goldCost)
        {
            return(false);
        }
        if (x.Costs.Length == 0)
        {
            return(true);
        }
        foreach (var item in x.Costs)
        {
            bool ok = false;
            foreach (var z in c)
            {
                if (item.Name == z.Name)
                {
                    ok = z.getAmount >= item.getAmount;
                }
            }

            if (!ok)
            {
                return(false);
            }
        }
        return(true);
    }
Beispiel #5
0
    //========================================
    void SelectUnit(int x)
    //========================================
    {
        Debug.Log(x);
        selectedUnit = unitsToCreate[x];

        unitText = unitButtons[x].GetComponentsInChildren <Text>();



        t_Name        = unitText[0];
        t_NickName    = unitText[1];
        t_RaceClass   = unitText[2];
        t_HealthMagic = unitText[3];

        if_GivenName.text = selectedUnit.givenName;
        if_SurName.text   = selectedUnit.surName;
        if_NickName.text  = selectedUnit.nickName;
    }