public Job[] GetStoneMineJobArray()
    {
        StoneMountain StoneMountain = FindStoneMountain();

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

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

        moveJob.position = StoneMountain.transform.position;

        Job stoneMineJob = new Job(Job.JobType.STONE_MINING);

        stoneMineJob.extra0 = StoneMountain;

        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, stoneMineJob, move2, dropJob, gotoJob, reportBackJob });
    }
    private StoneMountain FindStoneMountain()
    {
        StoneMountain result = null;

        for (int i = 0; i < stones.Count; i++)
        {
            if (stones[i] == null)
            {
                stones.RemoveAt(i);
            }
            else
            {
                result = stones[random.Next(0, stones.Count)];
                break;
            }
        }
        return(result);
    }
Example #3
0
    private void StoneMiningCommand(NPCLogic npcLogic, StoneMountain stoneMountain)
    {
        Job moveJob = new Job(Job.JobType.MOVE);

        moveJob.position = stoneMountain.transform.position;

        Job StoneMountain = new Job(Job.JobType.STONE_MINING);

        StoneMountain.extra0 = stoneMountain;

        if (Input.GetKey(KeyCode.LeftShift))
        {
            npcLogic.AddJob(moveJob);
            npcLogic.AddJob(StoneMountain);
        }
        else
        {
            npcLogic.SetJob(moveJob);
            npcLogic.AddJob(StoneMountain);
        }
    }
Example #4
0
    private void TestGiveStoneCutOrderCommand(NPCLogic npc, StoneMountain stoneMountain)
    {
        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 * StoneMineRadious;
            CurrentCurve         += Curve;
            otherMoveCmd.position = stoneMountain.transform.position + CircleVector;
            Debug.Log(CircleVector + " " + Curve);
            Job otherWoodCutOrder = new Job(Job.JobType.STONE_MINING);
            otherWoodCutOrder.extra0 = stoneMountain;
            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]);
                }
            }
        }
    }