public void init_arrive_at_city(Station_Track station_track) { base.arrive_at_city(); //city.add_train_to_list(gameObject); is_train_departed_for_turntable = false; //reset //station_track.train = gameObject; Vector3Int station_tile_position = station_track.start_location; VehicleManager.instance.depart(gameObject, station_tile_position, city.city_board); city.add_train_to_list(gameObject); }
public override void OnEndDrag(PointerEventData eventData) { Vector2Int final_tilemap_position = GameManager.get_selected_tile(eventData.position); Station_Track st = TrackManager.get_station_from_location(final_tilemap_position, CityManager.Activated_City_Component); string vehicle_type = clicked_item.tag; Destroy(clicked_item); if (GameManager.is_tutorial_mode) { bool is_wrong_place; if (vehicle_type == "train") { is_wrong_place = GameManager.tutorial_manager.is_click_in_wrong_place(final_tilemap_position, 4); } else { is_wrong_place = GameManager.tutorial_manager.is_click_in_wrong_place(final_tilemap_position); } if (is_wrong_place) { return; } } if (st == null) { return; // not a valid station } if (vehicle_type == "home" || vehicle_type == "work" || vehicle_type == "vacation" || vehicle_type == "food") { if (st.train == null || !st.train.GetComponent <Train>().is_wait_for_turntable || !st.train.GetComponent <Train>().is_boxcar_within_max_limit()) { return; // no train at this station } VehicleManager.instance.add_boxcar_to_train(st.train.GetComponent <Train>(), vehicle_type); } else if (vehicle_type.Contains("train")) { RouteManager.Orientation train_orientation = TrackManager.flip_straight_orientation(st.station.orientation); VehicleManager.instance.create_vehicle_at_home_base(train_orientation, st); } else { throw new Exception("nto a valid vehicle type"); } VehicleManager.update_vehicle_count(vehicle_type, -1); // "home", "food", "work", "vacation" update_inventory(); if (VehicleManager.get_vehicle_count(vehicle_type) == 0) { RawImage raw_image = clicked_go.GetComponent <RawImage>(); raw_image.texture = empty_inventory_bubble; } }
public void create_vehicle_at_home_base(RouteManager.Orientation orientation, Station_Track st) { // buying a new train in MenuManager train_counter++; GameObject new_train = Instantiate(Train); Train_List.Add(new_train); Train train_component = new_train.GetComponent <Train>(); train_component.initialize_orientation(orientation); train_component.in_city = true; train_component.set_id(train_counter); train_component.set_city(CityManager.home_base); // new vehicles always created at home base place_vehicle(new_train); // place the vehicle, which proceeds to depart train_component.station_track = st; train_component.init_arrive_at_city(st); // call immediately on instantiation. Otherwise, in_city = false and the wrong board is updated //st.train = new_train; BUG! If a train collides with one which is first }
public Station(Vector3Int outer_start, Vector3Int inner_start, RouteManager.Orientation orientation, Tilemap outer_track_tilemap, Tilemap inner_track_tilemap) { this.orientation = orientation; outer_track = new Station_Track(); outer_track.inner = 0; outer_track.tilemap = outer_track_tilemap; outer_track.start_location = outer_start; outer_track.train = null; outer_track.station = this; inner_track = new Station_Track(); inner_track.inner = 1; inner_track.tilemap = inner_track_tilemap; inner_track.start_location = inner_start; inner_track.train = null; inner_track.station = this; }
public void click_inventory(PointerEventData eventData) { // NOT GETTING CALLED selected_tile_pos = GameManager.get_selected_tile(eventData.position); selected_tile = (Tile)inventory_tilemap.GetTile((Vector3Int)selected_tile_pos); if (selected_tile != null) { List <List <int[]> > boxcar_action_coord = new List <List <int[]> >(); List <int[]> valid_unloading_pos_list = new List <int[]>(); Station_Track station_track = CityManager.Activated_City_Component.get_station_track(selected_tile_pos); // inner, outer doesnt matter RouteManager.Orientation[] orientation_list = new RouteManager.Orientation[] { RouteManager.Orientation.North, RouteManager.Orientation.East, RouteManager.Orientation.West, RouteManager.Orientation.South }; foreach (RouteManager.Orientation orientation in orientation_list) { List <List <int[]> > valid_boxcar_add_pos = TrackManager.add_to_train_coord_map[orientation]; bool train_in_outer_track = CityManager.Activated_City_Component.is_train_on_track(orientation, true); bool train_in_inner_track = CityManager.Activated_City_Component.is_train_on_track(orientation, false); //concatenate lists of outer track and inner track positions if (train_in_outer_track) { valid_unloading_pos_list.AddRange(valid_boxcar_add_pos[0]); } if (train_in_inner_track) { valid_unloading_pos_list.AddRange(valid_boxcar_add_pos[1]); } boxcar_action_coord.Add(valid_unloading_pos_list); } List <string> hint_context_list = new List <string>() { "add" }; GameObject.Find("GameManager").GetComponent <GameManager>().mark_tile_as_eligible(boxcar_action_coord, hint_context_list, gameObject, true); } }