Example #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);
        }
    }
Example #2
0
    public void Show(NPCLogic npcLogic)
    {
        textSelectedNPCName.text = npcLogic.name;
        var selectedNPCJob = npcLogic.npcData.jobQueue.jobs;

        if (selectedNPCJob.Count > 0)
        {
            if (selectedNPCJob.Count == 1)
            {
                textSelectedNPCCurrentJob.text = "Doing " + selectedNPCJob[0].jobType;
                textSelectedNPCNextJob.text    = "";
            }
            else
            {
                textSelectedNPCCurrentJob.text = "Doing " + selectedNPCJob[0].jobType;
                textSelectedNPCNextJob.text    = "Will Do " + selectedNPCJob[1].jobType;
            }
        }
        else
        {
            textSelectedNPCCurrentJob.text = "Nothing to do...";
            textSelectedNPCNextJob.text    = "";
        }

        if (npcLogic.npcData.workingOn != null && buttonSelectedNPCNWork == null)
        {
            var butt = UIManager.Instance.GetCorrectWorkIconRef(npcLogic.npcData.workingOn.GetWorkType());
            buttonSelectedNPCNWork = Instantiate(butt, Vector3.zero, Quaternion.identity);
            buttonSelectedNPCNWork.interactable = false;
            buttonSelectedNPCNWork.GetComponentInChildren <Text>().text = "";
            buttonSelectedNPCNWork.transform.SetParent(goSelectedNpcWork.transform);
            buttonSelectedNPCNWork.transform.localPosition = Vector3.zero;
        }
    }
Example #3
0
    // Update is called once per frame
    void Update()
    {
        if (currentJob == null)
        {
            return;
        }

        if (currentJob.jobType == Job.JobType.GOTO)
        {
            agent.isStopped = false;
            NPCLogic guy = (NPCLogic)currentJob.extra0;

            agent.SetDestination(guy.transform.position);
        }
        else if (currentJob.jobType == Job.JobType.REPORT_BACK)
        {
            var cheif = currentJob.extra0 as NPCLogic;
            var data  = currentJob.extra1 as string;

            if (Vector3.Distance(cheif.transform.position, transform.position) < NPCLogic.GIVE_ORDER_DISTANCE)
            {
                cheif.Report(npcData.npcLogic, data);
            }
        }
    }
Example #4
0
 private void MoveCommand(NPCLogic npcLogic, Vector3 destination)
 {
     if (Input.GetKey(KeyCode.LeftShift))
     {
         npcLogic.AddWaypoint(destination);
     }
     else
     {
         npcLogic.SetWaypoint(destination);
     }
 }
Example #5
0
    public void GiveWoodCutJobToWorker(NPCLogic worker)
    {
        var jobs = GetWoodCutJobArray();

        if (jobs != null)
        {
            foreach (var job in jobs)
            {
                worker.AddJob(job);
            }
        }
    }
Example #6
0
 /// <summary>
 /// Karakterler arası görev dağılımı bütün görevleri siler bunu ekler
 /// </summary>
 /// <param name="byWho"></param>
 /// <param name="order"></param>
 /// <param name="receivedCallback"></param>
 public void GiveSetOrder(NPCLogic byWho, Job order)
 {
     if (byWho != null /*Eğer karakteri sevmiyorsa görevi almasın falan filan logic buraya*/)
     {
         SetJob(order);
         byWho.InteractionReceive(this, "order_received");
     }
     else
     {
         byWho.InteractionReceive(this, "order_declined");
     }
 }
Example #7
0
    /// <summary>
    /// Karakterler arası görev dağılımı priority olarak ekler öncelikli görev olarak ekler
    /// </summary>
    /// <param name="byWho"></param>
    /// <param name="orders"></param>
    /// <param name="receivedCallback"></param>
    public void GivePriorityOrders(NPCLogic byWho, Job[] orders)
    {
        if (byWho != null /*Eğer karakteri sevmiyorsa görevi almasın falan filan logic buraya*/)
        {
            AddPriorityJobs(orders);

            byWho.InteractionReceive(this, "order_received");
        }
        else
        {
            byWho.InteractionReceive(this, "order_declined");
        }
    }
Example #8
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);
         }
     }
 }
Example #9
0
 /// <summary>
 /// Karakterler arası görev dağılımı bütün görevleri siler bunu ekler
 /// </summary>
 /// <param name="byWho"></param>
 /// <param name="orders"></param>
 /// <param name="receivedCallback"></param>
 public void GiveSetOrders(NPCLogic byWho, Job[] orders)
 {
     if (byWho != null /*Eğer karakteri sevmiyorsa görevi almasın falan filan logic buraya*/)
     {
         SetJob(orders[0]);
         for (int i = 1; i < orders.Length; i++)
         {
             AddJob(orders[i]);
         }
         byWho.InteractionReceive(this, "order_received");
     }
     else
     {
         byWho.InteractionReceive(this, "order_declined");
     }
 }
Example #10
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);
        }
    }
Example #11
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 #12
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);
        }
    }
Example #13
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);
        }
    }
Example #14
0
    /// <summary>
    /// This function is called by other npc's in the game
    /// </summary>
    /// <param name="whoIsReporting"> Who is doing to reportig </param>
    /// <param name="data"> Data that is being sent </param>
    public void Report(NPCLogic whoIsReporting, string data)
    {
        if (npcData.isCheif)
        {
            Debug.Log(name + " " + npcData.isCheif + " cheif and " + whoIsReporting.name + " is reporting");
            var workType = npcData.workingOn.GetWorkType();
            switch (workType)
            {
            case Work.WorkType.WOOD_HARVEST_WORK:
            {
                Debug.Log("HERE1");
                if (data.Equals("Completed"))
                {
                    Debug.Log("HERE2");
                    var woodHarvestWork = npcData.workingOn as HarvestWoodWork;
                    woodHarvestWork.GiveWoodCutJobToWorker(whoIsReporting);
                    whoIsReporting.InteractionReceive(this, data);
                }
            }

            break;

            case Work.WorkType.STONE_HARVEST_WORK:
            {
                Debug.Log("HERE1");
                if (data.Equals("Completed"))
                {
                    Debug.Log("HERE2");
                    var stoneHarvestWork = npcData.workingOn as HarvestStoneWork;
                    stoneHarvestWork.GiveStoneMineJobToWorker(whoIsReporting);
                    whoIsReporting.InteractionReceive(this, data);
                }
            }
            break;
            }
        }
        else
        {
        }
    }
Example #15
0
    /// <summary>
    /// Bu diğer npcler tarafından çağrılan fonksiyon bu sayede 2 npc arasında tuhaf callbacklere gerek kalmıyor
    /// </summary>
    /// <param name="who"></param>
    /// <param name="data"></param>
    public void InteractionReceive(NPCLogic who, string data)
    {
        switch (currentJob.jobType)
        {
        case Job.JobType.GIVEORDER:
        {
            var toWho = currentJob.extra0 as NPCData;

            if (toWho.Equals(who.npcData))
            {
                if (data.Equals("order_received"))
                {
                    CompleteCurrentLogicJob();
                }
                else
                {
                    FailCurrentLogicJob();
                }
            }
        }
        break;

        case Job.JobType.REPORT_BACK:
        {
            var toWho   = currentJob.extra0 as NPCLogic;
            var dataStr = currentJob.extra1 as string;

            if (toWho.Equals(who) && data.Equals(dataStr))
            {
                CompleteCurrentLogicJob();
            }
            else
            {
                FailCurrentLogicJob();
            }
        }
        break;
        }
    }
Example #16
0
 public abstract void SetCheif(NPCLogic cheif);
Example #17
0
 public abstract void RemoveWorker(NPCLogic worker);
Example #18
0
 public void SetNpc(NPCLogic npc)
 {
     this.npc      = npc;
     nameText.text = npc.name;
 }
Example #19
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]);
                }
            }
        }
    }
Example #20
0
 public void DynamicShow(NPCLogic npcLogic)
 {
     this.npcLogic = npcLogic;
 }
Example #21
0
 public void DisableDynamicShow()
 {
     this.npcLogic = null;
 }
Example #22
0
 public abstract void AddWorker(NPCLogic worker);
Example #23
0
 private void ToggleRunCommand(NPCLogic npcLogic)
 {
     npcLogic.npcData.npcController.ToggleRun();
 }