Esempio n. 1
0
    public bool GetNextTask()
    {
        double t               = VillageManager.Get().GetDayTime();
        Task   cur             = GetCurrent();
        int    currentTask_tmp = currentTask;

        if (cur != null)
        {
            //0 uhr umsprung
            if (t < cur.ParseTime())
            {
                currentTask_tmp = -1;
            }
        }

        int nextTask = currentTask_tmp + 1;

        if (nextTask < 0 || nextTask >= tasks.Count)
        {
            return(false);
        }

        Task next = tasks[nextTask];

        if (t >= next.ParseTime())
        {
            //Debug.Log(next.Info() + " - t:" + t + " parse:" + next.ParseTime());
            currentTask = nextTask;
            return(true);
        }

        return(false);
    }
Esempio n. 2
0
    public Building ParseTarget()
    {
        if (target == "" || target == null)
        {
            return(null);
        }
        //MAYBE add villagers later
        List <Building> builds = VillageManager.Get().GetBuildings();

        for (int i = 0; i < builds.Count; i++)
        {
            if (builds[i].objectName == target)
            {
                return(builds[i]);
            }
        }

        return(null);
    }
Esempio n. 3
0
    void Production()
    {
        if (GetComponent <SeasonFilter>() != null && GetComponent <SeasonFilter>().filter.Contains(VillageManager.Get().GetSeason()))
        {
            return;
        }                                                                                                                                              //if this building can't produce during current season
        if (workers.Count > 0)
        {
            productionTimer += VillageManager.Get().deltaTime;

            switch (currentProduction)
            {
            case ProductionEnum.NONE:
                break;

            case ProductionEnum.HAPPINESS:
                if (productionTimer > VillageManager.oneHour)
                {
                    productionTimer = 0;
                    TickCycle();
                }
                break;

            case ProductionEnum.IRON:
                if (productionTimer > VillageManager.oneHour)
                {
                    if (VillageManager.Get().pickaxe >= 1)
                    {
                        VillageManager.Get().pickaxe -= 1;
                        VillageManager.Get().iron    += 2;
                        productionTimer = 0;

                        TickCycle();                                 //only ticks if villager is actually working, since he's chilling otherwise having a "jolly good" time*
                    }
                }
                break;

            case ProductionEnum.PICKAXE:
                if (productionTimer > VillageManager.oneHour)
                {
                    if (VillageManager.Get().iron >= 1)
                    {
                        VillageManager.Get().pickaxe += 1;
                        VillageManager.Get().iron    -= 1;
                        productionTimer = 0;

                        TickCycle();
                    }
                }

                break;

            case ProductionEnum.BREAD:
                if (productionTimer > VillageManager.oneHour)
                {
                    if (VillageManager.Get().flour >= 1)
                    {
                        VillageManager.Get().bread += 4;
                        VillageManager.Get().flour -= 1;
                        productionTimer = 0;

                        TickCycle();
                    }
                }
                break;

            case ProductionEnum.FLOUR:
                if (productionTimer > VillageManager.oneHour)
                {
                    if (VillageManager.Get().wheat >= 3)
                    {
                        VillageManager.Get().flour += 1;
                        VillageManager.Get().wheat -= 3;
                        productionTimer = 0;

                        TickCycle();
                    }
                }
                break;

            case ProductionEnum.WHEAT:
                if (productionTimer > VillageManager.oneHour)
                {
                    VillageManager.Get().wheat += 1;
                    productionTimer = 0;

                    TickCycle();
                }
                break;
            }
        }
    }
Esempio n. 4
0
 void Awake()
 {
     VillageManager.Get().AddBuilding(this);
 }
Esempio n. 5
0
    void Movement()
    {
        Vector3 tmp = target;

        if (schedule.GetTarget() == null)
        {
            return;
        }
        //Debug.Log(tmp);
        if (Vector3.Distance(transform.position, tmp) != 0)
        {
            target             = new Vector3(target.x, 1, target.z);
            transform.position = Vector3.MoveTowards(transform.position, target, speed * VillageManager.Get().deltaTime);

            if (transform.position == target && !arrived)
            {
                //arrived at building
                Debug.Log("arrived");
                arrived = true;
                workplace.AddWorker(this);
            }
        }
    }
Esempio n. 6
0
 void Start()
 {
     VillageManager.Get().AddVillager(this);
     schedule.Reset();
 }