示例#1
0
    private void Update()
    {
        if (moveNPC)
        {
            moveNPC = false;

            NPCScheduleEvent npcScheduleEvent = new NPCScheduleEvent(0, 0, 0, 0, Weather.none, Season.none, sceneName, new GridCoordinate(finishPosition.x, finishPosition.y), eventAnimationClip);

            npcPath.BuildPath(npcScheduleEvent);
        }
    }
示例#2
0
    // Check until the moveNPC bool is triggered in the editor. Then create an NPCSchedule event for this movement we want to make, and build the path and have the NPC follow it
    private void Update()
    {
        if (moveNPC)
        {
            moveNPC = false;

            // Now scheduled event with the correct parameters
            NPCScheduleEvent npcScheduleEvent = new NPCScheduleEvent(0, 0, 0, 0, Weather.none, Season.none, sceneName, new GridCoordinate(finishPosition.x, finishPosition.y), eventAnimationClip);

            // Build the path from this npcScheduleEvent
            npcPath.BuildPath(npcScheduleEvent);
        }
    }
示例#3
0
    // This method is called every time the game Minute advances. It will loop through all of the npcScheduleEvents in the npcScheduleEventList
    // And see if we have a match (in time, day, season, weather, and priority if times match). If we do, this will call NPCPath
    // to build the path with AStar, and move the NPC accordingly with NPCMovement
    private void GameTimeSystem_AdvanceMinute(int gameYear, Season gameSeason, int gameDay, string gameDayOfWeek, int gameHour, int gameMinute, int gameSecond)
    {
        // Now that we know a minute has just advanced, get the current game time in the form of HHMM
        int time = (gameHour * 100) + gameMinute;

        // Attempt to get a matching schedule for this particular gameTime that just advanced to
        NPCScheduleEvent matchingNPCScheduleEvent = null;

        // Loop through all of the NPCScheduleEvents in the sorted set, which is already in time and priority order
        foreach (NPCScheduleEvent npcScheduleEvent in npcScheduleEventSet)
        {
            // First check if the current npcScheduleEvent occurs at the same time as the current game time
            if (npcScheduleEvent.Time == time)
            {
                // Now that the time matches, check if the parameters (day/season/weather) also match. If they don't, continue on to the next NPCScheduleEvent in the Set
                if (npcScheduleEvent.day != 0 && npcScheduleEvent.day != gameDay)
                {
                    continue;
                }
                if (npcScheduleEvent.season != Season.none && npcScheduleEvent.season != gameSeason)
                {
                    continue;
                }
                if (npcScheduleEvent.weather != Weather.none && npcScheduleEvent.weather != GameManager.Instance.currentWeather)
                {
                    continue;
                }

                // If all of the above checks pass (so we are on the correct time, day, season, and weather), we have a match! Play the Scheduled event! (build path, move NPC)
                // Note these are already sorted by priority, so the first match is automatically the correctly prioritized match for several schedules at the same time.
                // This will set matchingNPCScheduleEvent to the current NPCScheduleEvent, break out of the for loop, and then build the path down below
                matchingNPCScheduleEvent = npcScheduleEvent;
                break;
            }
            // If the time hasn't occured yet, dont do anything at all (The set is sorted by time, so if the current elements time hasn't occured yet, none of them will have!)
            else if (npcScheduleEvent.Time > time)
            {
                break;
            }
        }

        // Now, as long as we have found a matching event above (matchingNPCScheduleEvent isn't null anymore), Build the path with npcPath which takes
        // care of building the path with AStar, and moving the NPC with NPCMovement along the path, just by passing in this NPCScheduleEvent that matches the current time
        if (matchingNPCScheduleEvent != null)
        {
            npcPath.BuildPath(matchingNPCScheduleEvent);
        }
    }
示例#4
0
    private void GameTimeSystem_AdvanceMinute(int gameYear, Season gameSeason, int gameDay, string gameDayOfWeek, int gameHour, int gameMinute, int gameSecond)
    {
        int time = (gameHour * 100) + gameMinute;

        //Attempt to get matching schedule

        NPCScheduleEvent matchingNPCScheduleEvent = null;

        foreach (NPCScheduleEvent npcScheduleEvent in npcScheduleEventSet)
        {
            if (npcScheduleEvent.Time == time)
            {
                //Time match now check if parameters match
                if (npcScheduleEvent.day != 0 && npcScheduleEvent.day != gameDay)
                {
                    continue;
                }

                if (npcScheduleEvent.season != Season.none && npcScheduleEvent.season != gameSeason)
                {
                    continue;
                }

                if (npcScheduleEvent.weather != Weather.none && npcScheduleEvent.weather != GameManager.Instance.currentWeather)
                {
                    continue;
                }

                //Schdule matches
                //Debug.Log("Schedule Matches!" + npcScheduleEvent);
                matchingNPCScheduleEvent = npcScheduleEvent;
                break;
            }
            else if (npcScheduleEvent.Time > time)
            {
                break;
            }
        }

        //Now test is matchingSchedule != null and do something;
        if (matchingNPCScheduleEvent != null)
        {
            //Build path for matching schedule
            npcPath.BuildPath(matchingNPCScheduleEvent);
        }
    }