Exemple #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="view"></param>
        /// <param name="loc"></param>
        /// <param name="ab"></param>
        public override void OnClick(MapViewWindow view, Location loc, Point ab)
        {
            switch (currentMode)
            {
            case Mode.Station:
                if (isPlacing)
                {
                    if (!selectedStation.CanBeBuilt(loc, ControlMode.Player))
                    {
                        MessageBox.Show(Translation.GetString("CONSTRUCTION_CANNOT_BUILD"));
                    }
                    else
                    {
                        selectedStation.Create(loc, true);
                    }
                }
                else
                {
                    Station s = Station.get(loc);
                    if (s != null)
                    {
                        s.remove();
                    }
                }
                return;

            case Mode.FatPlatform:
                if (isPlacing)
                {
                    if (!FatPlatform.canBeBuilt(loc, direction, length))
                    {
                        MessageBox.Show(Translation.GetString("CONSTRUCTION_CANNOT_BUILD"));
                        return;
                    }
                    new FatPlatform(loc, direction, length);
                }
                else
                {
                    Platform p = Platform.get(loc);
                    if (p != null)
                    {
                        if (p.canRemove)
                        {
                            p.remove();
                        }
                        else
                        {
                            MessageBox.Show(Translation.GetString("CONSTRUCTION_CANNOT_REMOVE"));
                        }
                    }
                }
                return;

            case Mode.ThinPlatform:
                if (isPlacing)
                {
                    if (!ThinPlatform.canBeBuilt(loc, direction, length))
                    {
                        MessageBox.Show(Translation.GetString("CONSTRUCTION_CANNOT_BUILD"));
                        return;
                    }
                    new ThinPlatform(loc, direction, length);
                }
                else
                {
                    Platform p = Platform.get(loc);
                    if (p != null)
                    {
                        if (p.canRemove)
                        {
                            p.remove();
                        }
                        else
                        {
                            MessageBox.Show(Translation.GetString("CONSTRUCTION_CANNOT_REMOVE"));
                        }
                    }
                }
                return;
            }
        }
        public override void onClick(MapViewWindow view, Location loc, Point ab)
        {
            switch (currentMode)
            {
            case Mode.Station:
                if (isPlacing)
                {
                    if (!selectedStation.canBeBuilt(loc, ControlMode.player))
                    {
                        MainWindow.showError("Can not build");
                        //! MainWindow.showError("設置できません");
                    }
                    else
                    {
                        selectedStation.create(loc, true);
                    }
                }
                else
                {
                    Station s = Station.get(loc);
                    if (s != null)
                    {
                        s.remove();
                    }
                }
                return;

            case Mode.FatPlatform:
                if (isPlacing)
                {
                    if (!FatPlatform.canBeBuilt(loc, direction, length))
                    {
                        MainWindow.showError("Can not build");
                        //! MainWindow.showError("設置できません");
                        return;
                    }
                    new FatPlatform(loc, direction, length);
                }
                else
                {
                    Platform p = Platform.get(loc);
                    if (p != null)
                    {
                        if (p.canRemove)
                        {
                            p.remove();
                        }
                        else
                        {
                            MainWindow.showError("Can not remove");
                        }
                        //! MainWindow.showError("撤去できません");
                    }
                }
                return;

            case Mode.ThinPlatform:
                if (isPlacing)
                {
                    if (!ThinPlatform.canBeBuilt(loc, direction, length))
                    {
                        MainWindow.showError("Can not build");
                        //! MainWindow.showError("設置できません");
                        return;
                    }
                    new ThinPlatform(loc, direction, length);
                }
                else
                {
                    Platform p = Platform.get(loc);
                    if (p != null)
                    {
                        if (p.canRemove)
                        {
                            p.remove();
                        }
                        else
                        {
                            MainWindow.showError("Can not remove");
                        }
                        //! MainWindow.showError("撤去できません");
                    }
                }
                return;
            }
        }