Esempio n. 1
0
    //-------------------------------------------------------------------------------------------------
    // private methods
    //-------------------------------------------------------------------------------------------------

    private void setupType()
    {
        //sets up the type info in case it isnt initalised correct and so I can remember what it should be
        switch (mType)
        {
        case GameTypes.BuildingType.Unknown:
            Debug.LogError("Unknown Building type");
            break;

        case GameTypes.BuildingType.TownHall:
            getInventory().mCapacity = 200;
            mUnitInventory.mCapacity = 30;
            break;

        case GameTypes.BuildingType.House:
            getInventory().mCapacity = 15;
            mUnitInventory.mCapacity = 7;
            break;

        case GameTypes.BuildingType.Stockpile:
            getInventory().mCapacity = 1000;
            mUnitInventory.mCapacity = 2;
            break;

        default:
            WorkedBuilding wb = (WorkedBuilding)this;
            if (!wb)
            {
                Debug.LogError("Building type not recognised");
            }
            break;
        }
    }
Esempio n. 2
0
    private GameTypes.IconType needsIcon(Entity ent)
    {
        //check conditions for displaying certain icons above entities to convey information
        Unit           unit = ent as Unit;
        WorkedBuilding wb   = ent as WorkedBuilding;

        if (unit)
        {
            if (unit.isIdle())
            {
                return(GameTypes.IconType.Caution);
            }
        }
        else if (wb)
        {
            if (wb.needsWorkers())
            {
                return(GameTypes.IconType.Caution);
            }
        }
        return(GameTypes.IconType.Unknown);
    }
Esempio n. 3
0
    //-------------------------------------------------------------------------------------------------
    // public methods
    //-------------------------------------------------------------------------------------------------
    public void populate(Entity ent)
    {
        //clear menu
        clear();
        //populate the info for the Entity
        string  text = string.Format("Name: {0}\n", ent.mName);
        Vector3 epos = ent.transform.position;

        text += string.Format("Pos: ({0:0},{1:0})\n", epos.x, epos.z);
        EntityHP ent_hp = ent as EntityHP;

        if (ent)
        {
            //TEMP, see if the entity is in the visible  list
            foreach (Entity e in ObjectManager.getVisibleEntities())
            {
                if (ent == e)
                {
                    text += string.Format("Is Visible: True\n");
                    break;
                }
            }
        }
        if (ent_hp)
        {
            text += string.Format("HP: {0:0} \n", ent_hp.mHP);
        }
        EntityAction ent_act = ent as EntityAction;
        Unit         unit    = ent as Unit;

        if (ent_act)
        {
            if (!unit)
            {
                text += string.Format("InvCap.: {0:0} \n", ent_act.getInventory().mCapacity);
            }
            if (ent_act.mTown)
            {
                text += string.Format("Town: {0}\n", ent_act.mTown.mName);
                //text += string.Format("StockPile: {0}\n", ent_act.mTown.mStockpile.mName);
            }
        }
        Resource res = ent as Resource;

        if (res)
        {
            text += string.Format("Amount: {0:0} \n", res.mAmount);
        }
        //unit
        if (unit)
        {
            //hunger
            text += string.Format("Hunger: {0:0}\n", unit.getHunger());
            //garrison status
            if (unit.isGarrisoned())
            {
                text += string.Format("Garrison: {0}\n", unit.getGarrison().mName);
                setupUnitUngarrisonButton(unit, mButton1);
            }
            //gender
            text += string.Format("Gender: {0}\n", unit.getGender().ToString());
            //pregnancy
            if (unit.getGender() == GameTypes.GenderType.Female)
            {
                text += string.Format("Pregnant: {0}\n", unit.isPregnant().ToString());
                if (unit.isPregnant())
                {
                    text += string.Format("Preg.Prog.: {0:0}\n", unit.getPregnancyProgress());
                }
            }
            text += unit.printStats();
        }
        Building build = ent as Building;

        if (build)
        {
            text += string.Format("GarrisonCap.: {0}\n", build.getUnitInventory().mCapacity);
            text += string.Format("Garrisoned: {0}\n", build.getUnitInventorySize());
            if (build.getUnitInventorySize() > 0)
            {
                //make the ungarrisonall button
                setupBuildingUngarrisonButton(build, mButton1);
            }
        }
        Construction constro = ent as Construction;

        if (constro)
        {
            text += constro.printMaterialsMap();
            text += string.Format("Progress: {0:0}", constro.getProgress());
        }
        WorkedBuilding wb = ent as WorkedBuilding;

        if (wb)
        {
            text += string.Format("Progress: {0:0}\n", wb.displayProgress());
            text += string.Format("NumWorkers: {0}/{1}\n", wb.getNWorkers(), wb.getMaxWorkers());
            WorkedProdBuilding wpb = wb as WorkedProdBuilding;
            if (wpb)
            {
                text += wpb.printNeededItems();
            }
        }
        mText.text = text;
    }
Esempio n. 4
0
 public void setTarget(WorkedBuilding target)
 {
     mTarget = target;
 }
Esempio n. 5
0
    private List <string> getAvailableActionStrings()
    {
        //returns a list of strings which are the names of available actions
        List <string> titles = new List <string>();
        Entity        ent    = mHitObject as Entity;

        if (ent)
        {
            titles.Add("Move");
            titles.Add("Wait");
        }
        else if (mHitPoint != Globals.InvalidPosition)
        {
            titles.Add("Move");
            titles.Add("Wait");
            titles.Add("Construct");
        }
        else if (mHitPoint == Globals.InvalidPosition)
        {
            //Debug.Log("Adding explore to menu list");
            titles.Add("Explore");
        }
        EntityHP ent_hp = mHitObject as EntityHP;

        if (ent_hp)
        {
            titles.Add("Attack");
        }
        EntityAction ent_act = mHitObject as EntityAction;

        if (ent_act)
        {
            titles.Add("Exchange");
        }
        Building build = mHitObject as Building;

        if (build)
        {
            titles.Add("Garrison");
            titles.Add("Procreate");
            if (build.getType() == GameTypes.BuildingType.TownHall)
            {
                titles.Add("Travel");
            }
        }
        Resource res = mHitObject as Resource;

        if (res)
        {
            titles.Add("Collect");
        }
        WorkedBuilding wb = mHitObject as WorkedBuilding;

        if (wb)
        {
            titles.Add("Work");
        }
        Construction constr = mHitObject as Construction;

        if (constr)
        {
            titles.Add("Construct");
        }


        return(titles);
    }
Esempio n. 6
0
    public void setOutcome(string oname)
    {
        EntityHP       ent_hp  = mHitObject as EntityHP;
        EntityAction   ent_act = mHitObject as EntityAction;
        Entity         ent     = mHitObject as Entity;
        Resource       res     = mHitObject as Resource;
        Building       build   = mHitObject as Building;
        Construction   constro = mHitObject as Construction;
        WorkedBuilding wb      = mHitObject as WorkedBuilding;

        mOutcomeString = oname;
        switch (oname)
        {
        case "Move":
            //Debug.Log(string.Format("Action keyword Move chosen", oname));
            Movement move = ObjectManager.initMove(mSelection.transform);
            if (ent)
            {
                move.setDestination(ent);
            }
            else if (mHitPoint != Globals.InvalidPosition)
            {
                move.setDestination(mHitPoint);
            }
            mOutcomeAction = move;
            break;

        case "Wait":
            Wait wt = ObjectManager.initWait(mSelection.transform);
            if (ent)
            {
                wt.setDestination(ent);
            }
            else if (mHitPoint != Globals.InvalidPosition)
            {
                wt.setDestination(mHitPoint);
            }
            mOutcomeAction = wt;
            break;

        case "Attack":
            //Debug.Log(string.Format("Action keyword Attack chosen.", oname));
            Attack att = ObjectManager.initAttack(mSelection.transform);
            if (ent_hp)
            {
                att.setTarget(ent_hp);
                mOutcomeAction = att;
                break;
            }
            else
            {
                mOutcome = false;
            }
            setActive(false);
            return;

        case "Exchange":
            Exchange ex = ObjectManager.initExchange(mSelection.transform);
            if (ent_act)
            {
                ex.setTarget(ent_act);
                mOutcomeAction = ex;
                break;
            }
            else
            {
                mOutcome = false;
            }
            setActive(false);
            return;

        case "Garrison":
            Garrison gar = ObjectManager.initGarrison(mSelection.transform);
            if (build)
            {
                gar.setTarget(build);
                mOutcomeAction = gar;
                break;
            }
            else
            {
                mOutcome = false;
            }
            setActive(false);
            return;

        case "Procreate":
            Procreate proc = ObjectManager.initProcreate(mSelection.transform);
            if (build)
            {
                proc.setGarrisonBuilding(build);
                mOutcomeAction = proc;
                break;
            }
            else
            {
                mOutcome = false;
            }
            setActive(false);
            return;

        case "Collect":
            Collect coll = ObjectManager.initCollect(mSelection.transform);
            if (res)
            {
                coll.setTarget(res);
                mOutcomeAction = coll;
                break;
            }
            else
            {
                mOutcome = false;
            }
            setActive(false);
            return;

        case "Work":
            Work wr = ObjectManager.initWork(mSelection.transform);
            if (wr)
            {
                wr.setTarget(wb);
                mOutcomeAction = wr;
                break;
            }
            else
            {
                mOutcome = false;
            }
            setActive(false);
            return;

        case "Construct":
            if (constro)
            {
                Construct constr = ObjectManager.initConstruct(mSelection.transform);
                constr.setTarget(constro);
                mOutcomeAction = constr;
            }
            else if (mHitPoint != Globals.InvalidPosition)
            {
                populateListMenu();
                //constr.setTarget(mHitPoint);
            }
            else
            {
                mOutcome = false;
                setActive(false);
                return;
            }
            break;

        case "Explore":
            //Debug.Log("Explore action set as outcome");
            Explore exp = ObjectManager.initExplore(mSelection.transform);
            mOutcomeAction = exp;
            break;

        case "Travel":
            //Debug.Log("travel selected");
            Travel trav = ObjectManager.initTravel(mSelection.transform);
            if (build)
            {
                //Debug.Log("building is not null");
                trav.setDestination(build);
                mOutcomeAction = trav;
                break;
            }
            else
            {
                mOutcome = false;
                //Debug.Log("building is null");
            }
            setActive(false);
            break;

        default:
            Debug.LogError(string.Format("Action keyword {0} not recoginised.", oname));
            break;
        }
        if (!mListActive)
        {
            mOutcome = true;
        }
    }