コード例 #1
0
        public override void onClick(MapViewWindow view, Location loc, Point ab)
        {
            if (isPlacing)
            {
                TrafficVoxel tv = TrafficVoxel.getOrCreate(loc);
                if (tv == null)
                {
                    MainWindow.showError("There are obstacles");
                    //! MainWindow.showError("障害物があります");
                    return;
                }

                if (tv.railRoad == null || tv.railRoad is SingleRailRoad)
                {
                    new SignalRailRoad(tv, currentType, currentDirection);
                }
                else
                {
                    MainWindow.showError("Can not place on this rail");
                }
                //! MainWindow.showError("設置できない線路です");
            }
            else
            {
                SignalRailRoad srr = RailRoad.get(loc) as SignalRailRoad;
                if (srr != null)
                {
                    srr.remove();
                }
            }
        }
コード例 #2
0
        /// <summary> LocationDisambiguator implementation </summary>
        public bool IsSelectable(Location loc)
        {
            if (currentMode == Mode.Station)
            {
                return(GroundDisambiguator.theInstance.IsSelectable(loc));
            }

            if (isPlacing)
            {
                // align to RRs or the ground

                if (currentMode == Mode.FatPlatform)
                {
                    loc += direction.right90;
                }

                if (GroundDisambiguator.theInstance.IsSelectable(loc))
                {
                    return(true);
                }

                RailRoad rr = RailRoad.get(loc);
                if (rr == null)
                {
                    return(false);
                }
                return(rr.hasRail(direction) && rr.hasRail(direction.opposite));
            }
            else
            {
                return(Platform.get(loc) != null);
            }
        }
コード例 #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="loc"></param>
        /// <returns></returns>
        public bool IsSelectable(Location loc)
        {
            RailRoad rr = RailRoad.get(loc);

            if (rr == null)
            {
                return(false);
            }

            if (isPlacingMode)
            {
                if (rr.Voxel.car == null)
                {
                    return(true);
                }

                Train.TrainCar car = rr.Voxel.car as Train.TrainCar;
                if (car != null && car.parent == selectedTrain)
                {
                    // allow selecting the same train to reverse the direction
                    return(true);
                }

                return(false);
            }
            else
            {
                return(rr.Voxel.car != null);
            }
        }
コード例 #4
0
        /// <summary>
        /// LocationDisambiguator implementation.
        /// Use the base of the slope to disambiguate.
        /// </summary>
        /// <param name="loc"></param>
        /// <returns></returns>
        public bool isSelectable(Location loc)
        {
            if (!isPlacing)
            {
                SlopeRailRoad rr = SlopeRailRoad.get(loc);
                if (rr != null && rr.level < 2)
                {
                    return(true);
                }

                loc.z++;
                rr = SlopeRailRoad.get(loc);
                if (rr != null && rr.level >= 2)
                {
                    return(true);
                }

                return(false);
            }
            else
            {
                // it is always allowed to place it on or under ground
                if (World.world.getGroundLevel(loc) >= loc.z)
                {
                    return(true);
                }

                // if the new rail road is at the edge of existing rail,
                // allow.
                RailRoad rr = RailRoad.get(loc + direction.opposite);
                if (rr != null && rr.hasRail(direction))
                {
                    return(true);
                }

                for (int i = 0; i < 4; i++)
                {
                    loc += direction;
                }
                loc.z++;

                // run the same test to the other end
                rr = RailRoad.get(loc);
                if (rr != null && rr.hasRail(direction.opposite))
                {
                    return(true);
                }

                return(false);
            }
        }
コード例 #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="loc"></param>
        /// <returns></returns>
        public bool IsSelectable(Location loc)
        {
            // if there's any rail roads, fine
            if (RailRoad.get(loc) != null)
            {
                return(true);
            }

            // or if we hit the ground
            if (WorldDefinition.World.GetGroundLevel(loc) >= loc.z)
            {
                return(true);
            }

            return(false);
        }
コード例 #6
0
ファイル: TrainGarage.cs プロジェクト: hayate891/freetrain
        public override void remove(Location here, Location to)
        {
            if (here == to)
            {
                return;
            }

            Direction d = here.getDirectionTo(to);

            for ( ; here != to; here = here.toward(to))
            {
                GarageRail grr = RailRoad.get(here) as GarageRail;
                if (grr != null && grr.hasRail(d))
                {
                    grr.remove();                       // destroy it
                }
            }
        }
コード例 #7
0
 public static new SignalRailRoad get(Location loc)
 {
     return(RailRoad.get(loc) as SignalRailRoad);
 }
コード例 #8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="source"></param>
        /// <param name="loc"></param>
        /// <param name="ab"></param>
        public override void OnClick(MapViewWindow source, Location loc, Point ab)
        {
            if (isPlacingMode)
            {
                if (this.selectedTrain == null)
                {
                    return;
                }

                // place
                Train tr = this.selectedTrain;
                if (tr.isPlaced)
                {
                    // see if the user has clicked the same train
                    Car c = Car.Get(loc);
                    if (c is Train.TrainCar && ((Train.TrainCar)c).parent == tr)
                    {
                        // clicking the same train will be considered to reverse its direction
                        // and change the position of arrow
                        tr.reverse();
                        resetArrowLocation();
                        return;
                    }
                    else
                    {
                        MessageBox.Show(Translation.GetString("CONTROLLER_TRAIN_ALREADYPLACED"));
                        return;
                    }
                }

                RailRoad rr = RailRoad.get(loc);
                if (rr == null)
                {
                    MessageBox.Show(Translation.GetString("CONTROLLER_TRAIN_CANNOTPLACE_NOTRACKS"));
                    return;
                }

                if (!tr.place(loc))
                {
                    MessageBox.Show(Translation.GetString("CONSTRUCTION_CANNOT_PLACE"));
                }
                else
                {
                    playSound();
                }
            }
            else
            {
                // remove
                RailRoad rr = RailRoad.get(loc);
                if (rr == null)
                {
                    MessageBox.Show(Translation.GetString("CONTROLLER_TRAIN_NORAIL"));
                    return;
                }
                if (!(rr.Voxel.car is Train.TrainCar))
                {
                    MessageBox.Show(Translation.GetString("CONTROLLER_TRAIN_NOCARS"));
                    return;
                }
                ((Train.TrainCar)rr.Voxel.car).parent.remove();
                playSound();
                // successfully removed
            }
        }
コード例 #9
0
        public override void onClick(MapViewWindow source, Location loc, Point ab)
        {
            if (isPlacingMode)
            {
                if (this.selectedTrain == null)
                {
                    return;
                }

                // place
                Train tr = this.selectedTrain;
                if (tr.isPlaced)
                {
                    // see if the user has clicked the same train
                    Car c = Car.get(loc);
                    if (c is Train.TrainCar && ((Train.TrainCar)c).parent == tr)
                    {
                        // clicking the same train will be considered to reverse its direction
                        // and change the position of arrow
                        tr.reverse();
                        resetArrowLocation();
                        return;
                    }
                    else
                    {
                        MainWindow.showError("This train is already placed");
                        //; MainWindow.showError("配置済みです");
                        return;
                    }
                }

                RailRoad rr = RailRoad.get(loc);
                if (rr == null)
                {
                    MainWindow.showError("Can not place without tracks");
                    //; MainWindow.showError("線路のないところには配置できません");
                    return;
                }

                if (!tr.place(loc))
                {
                    MainWindow.showError("Can not place");
                    //! MainWindow.showError("配置できません");
                }
                else
                {
                    playSound();
                }
            }
            else
            {
                // remove
                RailRoad rr = RailRoad.get(loc);
                if (rr == null)
                {
                    MainWindow.showError("There are no tracks");
                    //! MainWindow.showError("線路がありません");
                    return;
                }
                if (!(rr.voxel.car is Train.TrainCar))
                {
                    MainWindow.showError("There are no cars");
                    //! MainWindow.showError("車両がありません");
                    return;
                }
                ((Train.TrainCar)rr.voxel.car).parent.remove();
                playSound();
                // successfully removed
            }
        }