示例#1
0
    public Job[] GetFoodFarmJobArray()
    {
        GrainField GrainField = Findfoodfield();

        if (GrainField == null)
        {
            Debug.LogAssertion("AAAAA FIX THISSSS");
            return(null);
        }

        Job moveJob = new Job(Job.JobType.MOVE);

        moveJob.position = GrainField.transform.position;

        Job foodFarmJob = new Job(Job.JobType.FARMING);

        foodFarmJob.extra0 = GrainField;

        Job move2 = new Job(Job.JobType.MOVE);

        move2.position = dropOffLocation[0].position;

        Job dropJob = new Job(Job.JobType.ITEM_DROP);

        Job gotoJob = new Job(Job.JobType.GOTO);

        gotoJob.extra0 = cheif;

        Job reportBackJob = new Job(Job.JobType.REPORT_BACK);

        reportBackJob.extra0 = cheif;
        reportBackJob.extra1 = "Completed";

        return(new Job[] { moveJob, foodFarmJob, move2, dropJob, gotoJob, reportBackJob });
    }
示例#2
0
    private GrainField Findfoodfield()
    {
        GrainField result = null;

        for (int i = 0; i < food.Count; i++)
        {
            if (food[i] == null)
            {
                food.RemoveAt(i);
            }
            else
            {
                result = food[random.Next(0, food.Count)];
                break;
            }
        }
        return(result);
    }
示例#3
0
    private void FoodFarmingCommand(NPCLogic npcLogic, GrainField grainField)
    {
        Job moveJob = new Job(Job.JobType.MOVE);

        moveJob.position = grainField.transform.position;

        Job GrainField = new Job(Job.JobType.FARMING);

        GrainField.extra0 = grainField;

        if (Input.GetKey(KeyCode.LeftShift))
        {
            npcLogic.AddJob(moveJob);
            npcLogic.AddJob(GrainField);
        }
        else
        {
            npcLogic.SetJob(moveJob);
            npcLogic.AddJob(GrainField);
        }
    }
示例#4
0
    private void TestGiveFoodCutOrderCommand(NPCLogic npc, GrainField grainField)
    {
        var        others       = FindObjectsOfType <NPCLogic>();
        List <Job> jobs         = new List <Job>();
        double     CurrentCurve = 0;
        double     Curve        = (double)(360) / (double)(others.Length);
        Vector3    x            = new Vector3(0, 0, 0);
        Vector3    z            = new Vector3(0, 0, 0);

        foreach (var other in others)
        {
            if (other.Equals(npc))
            {
                continue;
            }

            Job gotoJob = new Job(Job.JobType.GOTO);
            gotoJob.extra0 = other;

            Job otherMoveCmd = new Job(Job.JobType.MOVE);

            var CircleVector = Quaternion.AngleAxis((float)(CurrentCurve), Vector3.up) * Vector3.forward * FoodFarmRadious;
            CurrentCurve         += Curve;
            otherMoveCmd.position = grainField.transform.position + CircleVector;
            Debug.Log(CircleVector + " " + Curve);
            Job otherWoodCutOrder = new Job(Job.JobType.FARMING);
            otherWoodCutOrder.extra0 = grainField;
            Job otherMove2Cmd = new Job(Job.JobType.MOVE);


            if (others.Length == 1)
            {
                otherMove2Cmd.position = npc.transform.position;
            }
            else if (others.Length > 1)
            {
                if (x.x > Math.Sqrt(others.Length))
                {
                    z.z++;
                    x.x = 0;
                }
                otherMove2Cmd.position = npc.transform.position - new Vector3(x.x, 1, z.z);

                x.x++;
                //Debug.Log(x.x + " " + z.z + " " + Math.Sqrt(selectedNPCLogic.Count) + " " + npcLogic.name);
            }



            Job otherDropCmd = new Job(Job.JobType.ITEM_DROP);

            Job goto2Job = new Job(Job.JobType.GOTO);
            goto2Job.extra0 = npc;

            Job otherReportback = new Job(Job.JobType.REPORT_BACK);
            otherReportback.extra0 = npc;

            Job[] otherJobs = new Job[] { otherMoveCmd, otherWoodCutOrder, otherMove2Cmd, otherDropCmd, goto2Job, otherReportback };

            Job giveOrder = new Job(Job.JobType.GIVEORDER);
            giveOrder.extra0 = other.npcData;
            giveOrder.extra1 = otherJobs;

            jobs.Add(gotoJob);
            jobs.Add(giveOrder);
        }

        if (Input.GetKey(KeyCode.LeftShift))
        {
            foreach (var job in jobs)
            {
                npc.AddJob(job);
            }
        }
        else
        {
            for (int i = 0; i < jobs.Count; i++)
            {
                if (i == 0)
                {
                    npc.SetJob(jobs[i]);
                }
                else
                {
                    npc.AddJob(jobs[i]);
                }
            }
        }
    }