Ejemplo n.º 1
0
    private void ItemTransfer(NPCLogic npcLogic, NPCLogic otherGuy)
    {
        Job gotoJob = new Job(Job.JobType.GOTO);

        gotoJob.extra0 = otherGuy;

        Job giveOrder = new Job(Job.JobType.GIVEORDER);

        giveOrder.extra0 = otherGuy.npcData;

        Job receiveJob = new Job(Job.JobType.ITEM_RECEIVE);

        receiveJob.extra0 = npcLogic;
        giveOrder.extra1  = receiveJob;

        Job itemTransfer = new Job(Job.JobType.ITEM_TRANSFER);

        itemTransfer.extra0 = otherGuy;

        if (Input.GetKey(KeyCode.LeftShift) && (npcLogic.npcData.jobQueue.HasPickUpJob() || npcLogic.npcData.carryingItem != null))
        {
            npcLogic.AddJob(gotoJob);
            npcLogic.AddJob(giveOrder);
            npcLogic.AddJob(itemTransfer);
        }
        else if (npcLogic.npcData.carryingItem != null)
        {
            npcLogic.SetJob(gotoJob);
            npcLogic.AddJob(giveOrder);
            npcLogic.AddJob(itemTransfer);
        }
    }
Ejemplo n.º 2
0
    public void GiveWoodCutJobToWorker(NPCLogic worker)
    {
        var jobs = GetWoodCutJobArray();

        if (jobs != null)
        {
            foreach (var job in jobs)
            {
                worker.AddJob(job);
            }
        }
    }
Ejemplo n.º 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);
        }
    }
Ejemplo n.º 4
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);
        }
    }
Ejemplo n.º 5
0
    private void WoodCuttingCommand(NPCLogic npcLogic, WoodTree woodTree)
    {
        Job moveJob = new Job(Job.JobType.MOVE);

        moveJob.position = woodTree.transform.position;

        Job WoodCutting = new Job(Job.JobType.WOOD_CUTTING);

        WoodCutting.extra0 = woodTree;

        if (Input.GetKey(KeyCode.LeftShift))
        {
            npcLogic.AddJob(moveJob);
            npcLogic.AddJob(WoodCutting);
        }
        else
        {
            npcLogic.SetJob(moveJob);
            npcLogic.AddJob(WoodCutting);
        }
    }
Ejemplo n.º 6
0
    private void PickUpCommand(NPCLogic npcLogic, Pickupable item)
    {
        Job moveJob = new Job(Job.JobType.MOVE);

        moveJob.position = item.transform.position;

        Job pickupJob = new Job(Job.JobType.ITEM_PICKUP);

        pickupJob.extra0 = item;

        if (Input.GetKey(KeyCode.LeftShift))
        {
            npcLogic.AddJob(moveJob);
            npcLogic.AddJob(pickupJob);
        }
        else
        {
            npcLogic.SetJob(moveJob);
            npcLogic.AddJob(pickupJob);
        }
    }
Ejemplo n.º 7
0
 private void DropCommand(NPCLogic npcLogic)
 {
     if ((npcLogic.npcData.carryingItem != null || npcLogic.npcData.jobQueue.HasPickUpJob()))
     {
         Job drobJob = new Job(Job.JobType.ITEM_DROP);
         if (Input.GetKey(KeyCode.LeftShift))
         {
             npcLogic.AddJob(drobJob);
         }
         else
         {
             npcLogic.SetJob(drobJob);
         }
     }
 }
Ejemplo n.º 8
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]);
                }
            }
        }
    }