コード例 #1
0
    // create an entry that begins at the given time between two key points. return the time the next entry should begin at.
    private int build_schedule_part(int start_min, KeyPoint from, KeyPoint to, ref ScheduleData schedule_data, string map_id, TileMapScript map_data)
    {
        var from_point = map_data.get_key_point(from);
        var to_point   = map_data.get_key_point(to);

        // get the path between the two points
        var path = world_generator.get_path(from_point, to_point, map_data.get_raw_data(), false);

        // make sure that a path exists first (if not there's a bug somewhere. this shouldn't happen because world gen ensures a path exists.)
        if (path.Count == 0)
        {
            Debug.Log(string.Format("Can't make entry in {4} from ({0}, {1}) to ({2},{3})",
                                    from_point[0], from_point[1], to_point[0], to_point[1], map_id));
            map_data.print_map();
            return(-1);
        }

        var path_length           = path.Count - 1;
        var MERCHANT_MIN_PER_TILE = 1.0f;

        // the time to be at the destination is proportional to the length of the path times the merchant's speed
        // it's set so that it gives the perfect amount of time for the merchant to get there on time
        int finish_time = start_min + (int)(MERCHANT_MIN_PER_TILE * path_length);

        schedule_data.insertEntry(create_schedule_entry(start_min, map_id, from_point[0], from_point[1]));
        schedule_data.insertEntry(create_schedule_entry(finish_time, map_id, to_point[0], to_point[1]));

        // return the next time to create an entry at, which is WAITING_TIME more than the finish time, because the merchant waits at the spot for WAITING_TIME
        var WAITING_TIME_IN_MIN = 25;

        finish_time += WAITING_TIME_IN_MIN;
        return(finish_time);
    }
コード例 #2
0
    // create an entry that begins at the given time between two key points. return the time the next entry should begin at.
    private int build_schedule_part(int start_min, KeyPoint from, KeyPoint to, ref ScheduleData schedule_data, string map_id, TileMapScript map_data)
    {
        var from_point = map_data.get_key_point(from);
        var to_point = map_data.get_key_point(to);

        // get the path between the two points
        var path = world_generator.get_path(from_point, to_point, map_data.get_raw_data(), false);

        // make sure that a path exists first (if not there's a bug somewhere. this shouldn't happen because world gen ensures a path exists.)
        if (path.Count == 0) {
            Debug.Log(string.Format("Can't make entry in {4} from ({0}, {1}) to ({2},{3})",
                from_point[0], from_point[1], to_point[0], to_point[1], map_id));
            map_data.print_map();
            return -1;
        }

        var path_length = path.Count - 1;
        var MERCHANT_MIN_PER_TILE = 1.0f;

        // the time to be at the destination is proportional to the length of the path times the merchant's speed
        // it's set so that it gives the perfect amount of time for the merchant to get there on time
        int finish_time = start_min + (int) (MERCHANT_MIN_PER_TILE * path_length);

        schedule_data.insertEntry(create_schedule_entry(start_min, map_id, from_point[0], from_point[1]));
        schedule_data.insertEntry(create_schedule_entry(finish_time, map_id, to_point[0], to_point[1]));

        // return the next time to create an entry at, which is WAITING_TIME more than the finish time, because the merchant waits at the spot for WAITING_TIME
        var WAITING_TIME_IN_MIN = 25;
        finish_time += WAITING_TIME_IN_MIN;
        return finish_time;
    }
コード例 #3
0
ファイル: TileMapScript.cs プロジェクト: ryanjk/PinkPlatypus
 // Get the position of a key point
 public int[] get_key_point(TileMapData.KeyPoint key_point)
 {
     return(_tileMapData.get_key_point(key_point));
 }