Example #1
0
    public void GenerateTestGatherTask()
    {
        // Grab necessary info
        Resource        resource = ResourceManager.Instance.GetResource(ResourceType.Food);
        ResourceDropoff dropoff  = ResourceManager.Instance.GetDropOff(ResourceType.Food);

        // Create sub tasks
        // First, go to resource
        WalkTask goToResource = new WalkTask();

        goToResource.Initialise(m_unit);
        goToResource.SetWalkToLocation(resource.transform.position);
        m_subTasks.Enqueue(goToResource);

        // Then gather resource
        GatherTask gatherResource = new GatherTask();

        gatherResource.SetResource(resource);
        gatherResource.Initialise(m_unit);
        m_subTasks.Enqueue(gatherResource);

        // Walk to drop off
        WalkTask goToDropoff = new WalkTask();

        goToDropoff.Initialise(m_unit);
        goToDropoff.SetWalkToLocation(dropoff.transform.position);
        m_subTasks.Enqueue(goToDropoff);

        // Drop off resource
        EmptyInventoryTask emptyAtDropoff = new EmptyInventoryTask();

        emptyAtDropoff.SetDropoff(dropoff);
        emptyAtDropoff.Initialise(m_unit);
        m_subTasks.Enqueue(emptyAtDropoff);
    }
        public void Stop()
        {
            if (WalkTask != null)
            {
                WalkTask.Wait(0);
            }

            Interrupt();
        }
Example #3
0
 void Start()
 {
     _input.MainInputAction
     .TakeUntilDestroy(this).Subscribe(pos =>
     {
         var walkTarget = Camera.main.ScreenToWorldPoint(pos);
         Debug.Log("wakj");
         var task = new WalkTask(walkTarget);
         _selection.CurrentSelection.Value.ScheduleTask(task);
     });
 }
Example #4
0
    private void CreateRunFromFireTask()
    {
        debugHolder.Log("Started creating fire task", eDebugImportance.Unimportant);
        RoomInformation selectedRoom = roomGraph.FindRoomFromStartMatching((x) => x >= 3, currentRoom.ID);

        if (selectedRoom != null)
        {
            hasCreatedFireTask = true;
            WalkTask walkTask = new WalkTask("Walk-RunFromFire", TaskScope.Personal, selectedRoom.GetRandomSpotInsideRoom, 10, 0, false, 2, () => { hasCreatedFireTask = false; debugHolder.Log("I am done running", eDebugImportance.Important); return(true); });
            personalTasks.AddTask(walkTask);
            debugHolder.Log("Created Fire Task", eDebugImportance.Unimportant);
            isOnFire = false;
        }
        else
        {
            debugHolder.Log("Could not find a room to create the fire task", eDebugImportance.Error);
            WanderTask wanderTask = new WanderTask("Panic", TaskScope.Personal, currentRoom.GetRandomSpotInsideRoom, () => isOnFire, 10, 0, false, 2, 4, eAnimationType.Panic, CreatePanicTaskIfStillOnFire);
            AddNewTask(wanderTask);
            isOnFire = true;
        }
    }