Пример #1
0
 public void OnSpawn(bool enterStore)
 { // If spawning outside the store
     if (dm == null)
     {
         Start();
     }
     if (enterStore)
     {
         enteringStore = true;
         dispensary    = GameObject.Find("Dispensary").GetComponent <Dispensary>();
         StoreObjectFunction_Doorway target = dispensary.Main_c.GetRandomEntryDoor();
         pathfinding.currentAction = CustomerPathfinding.CustomerAction.enteringStore;
         pathfinding.GetOutdoorPath(target.transform.position, OnEnterStore);
     }
     else
     {
         enteringStore = false;
         int     rand      = UnityEngine.Random.Range(0, 6);
         Vector3 targetPos = dm.gameObject.GetComponent <CustomerManager>().customerSpawnLocations[rand].transform.position;
         pathfinding.currentAction = CustomerPathfinding.CustomerAction.bypassingStore;
         pathfinding.GetOutdoorPath(targetPos);
     }
     pathfinding.speed = UnityEngine.Random.Range(4.20f, 7f);
     SetupDesired();
     pathfinding.outside = true;
 }
Пример #2
0
 public void OnPlace()
 {
     if (HasDisplayShelfFunction())
     {
         StoreObjectFunction_DisplayShelf displayShelf = GetDisplayShelfFunction();
         displayShelf.OnPlace();
     }
     if (HasCheckoutCounterFunction())
     {
         StoreObjectFunction_CheckoutCounter checkoutCounter = GetCheckoutCounterFunction();
         checkoutCounter.OnPlace();
     }
     if (HasBudtenderCounterFunction())
     {
         StoreObjectFunction_BudtenderCounter budtenderCounter = GetBudtenderCounterFunction();
         budtenderCounter.OnPlace();
     }
     if (HasDecorationFunction())
     {
         StoreObjectFunction_Decoration decoration = GetDecorationFunction();
         decoration.OnPlace();
     }
     if (HasDoorwayFunction())
     {
         StoreObjectFunction_Doorway doorway = GetDoorwayFunction();
         doorway.OnPlace();
     }
 }
    public void GeneratePathToExitDoorway()
    {
        StoreObjectFunction_Doorway       door    = customer.dm.dispensary.Main_c.GetRandomEntryDoor();
        Func <Vector3[], bool, Vector3[]> getPath = OnIndoorPathFound;

        DispensaryPathRequestManager.RequestPath(customer.dm.dispensary.grid, transform.position, door.transform.position, getPath);
    }
    public void NextAction()
    {
        if (pathfinding == null)
        {
            Start();
        }
        switch (action)
        {
        case DriverAction.goingToGetStack:
            if (truck.boxStacks.Count > 0)
            {
                if (pathfinding.indoors)
                {
                    StoreObjectFunction_Doorway door = dm.dispensary.Main_c.GetRandomEntryDoor();
                    pathfinding.GetIndoorPath(door.transform.position, ExitDispensary);
                }
                else
                {
                    pathfinding.GetOutdoorPath(truck.vehicleLoadingPosition.transform.position, PickupStack);
                }
            }
            else
            {
                action = DriverAction.goingToTruck;
                NextAction();
            }
            break;

        case DriverAction.droppingOffStack:
            if (!pathfinding.indoors)
            {
                StoreObjectFunction_Doorway door = dm.dispensary.Main_c.GetRandomEntryDoor();
                pathfinding.GetOutdoorPath(door.transform.position, EnterDispensary);
            }
            else
            {
                pathfinding.GetIndoorPath(currentStack.boxStackPosition, DropStack);
            }
            break;

        case DriverAction.goingToTruck:
            if (pathfinding.indoors)
            {
                StoreObjectFunction_Doorway door = dm.dispensary.Main_c.GetRandomEntryDoor();
                pathfinding.GetIndoorPath(door.transform.position, ExitDispensary);
            }
            else
            {
                pathfinding.GetOutdoorPath(truck.vehicleEnterExitPosition.transform.position, EnterTruck);
            }
            break;
        }
    }
Пример #5
0
    public bool HasDoorwayFunction()
    {
        StoreObjectFunction_Doorway potentialDoorwayFunction = gameObject.GetComponent <StoreObjectFunction_Doorway>();

        if (potentialDoorwayFunction != null)
        {
            return(true);
        }
        else
        {
            return(false);
        }
    }
Пример #6
0
    bool carriedOutAction = false; // if the current action is changed and onthink detects it, it will call the necessary pathfinding
                                   // method then set the boolean to true, until changed again
    IEnumerator OnThink()
    {
        while (true)
        {
            //print("Thinking: " + currentAction);
            if (!carriedOutAction)
            {
                switch (currentAction)
                {
                case StaffAction.awaitingJobAction:
                    DetermineJobAction();
                    carriedOutAction = true;
                    break;

                case StaffAction.performingJobAction:
                    // do nothing, this shouldnt land here ever anyways
                    print("Performing job action");
                    break;

                case StaffAction.finishedJobAction:
                    DetermineFinishedJobAction();
                    //print("Calling finished action");
                    carriedOutAction = true;
                    break;

                case StaffAction.enteringStore:
                    Dispensary dispensary = GameObject.Find("Dispensary").GetComponent <Dispensary>();
                    StoreObjectFunction_Doorway target = dispensary.Main_c.GetRandomEntryDoor();
                    GetOutdoorPath(target.transform.position);
                    carriedOutAction = true;
                    break;

                case StaffAction.leavingStore:
                    GeneratePathToExitDoorway();
                    carriedOutAction = true;
                    break;

                case StaffAction.waiting:
                    print(staff.parentStaff.staffName + " has no job");
                    carriedOutAction = true;
                    break;
                }
            }
            yield return(new WaitForSeconds(.2f)); // thinks 5 times per second
        }
    }
Пример #7
0
    public StoreObjectFunction_Doorway GetMainDoorway()
    {
        StoreObjectFunction_Doorway backupDoorway = null;

        foreach (StoreObject obj in storeObjects)
        {
            if (obj.functionHandler.HasDoorwayFunction())
            {
                StoreObjectFunction_Doorway doorway = obj.functionHandler.GetDoorwayFunction();
                if (doorway.mainDoorway)
                {
                    return(doorway);
                }
                else
                {
                    backupDoorway = doorway;
                }
            }
        }
        return(backupDoorway);
    }