Ejemplo n.º 1
0
    protected override void OnCreate()
    {
        InitTrans();

        BindListener(MainMenuButton_Button, delegate
        {
            Jyx2_UIManager.Instance.HideUI("SystemUIPanel");
            List <string> selectionContent = new List <string>()
            {
                "是", "否"
            };
            Jyx2_UIManager.Instance.ShowUI("ChatUIPanel", ChatType.Selection, "主角", "将丢失未保存进度,是否继续?", selectionContent, new Action <int>((index) =>
            {
                if (index == 0)
                {
                    LoadingPanel.Create("0_GameStart", () => { });
                }
            }));
        });


        //返回游戏
        BindListener(QuitGameButton_Button, () =>
        {
            Jyx2_UIManager.Instance.HideUI("SystemUIPanel");
            //Application.Quit();
        });

        BindListener(SaveButton_Button, delegate
        {
            Jyx2_UIManager.Instance.ShowUI("SavePanel", new Action <int>((index) =>
            {
                var levelMaster = FindObjectOfType <LevelMaster>();
                levelMaster.OnManuelSave(index);
            }));
        });

        BindListener(LoadButton_Button, () =>
        {
            Jyx2_UIManager.Instance.ShowUI("SavePanel", new Action <int>((index) =>
            {
                StoryEngine.DoLoadGame(index);
                Jyx2_UIManager.Instance.HideUI("SystemUIPanel");
            }));
        });

        BindListener(GraphicSettingsButton_Button, delegate
        {
            Jyx2_UIManager.Instance.HideUI("SystemUIPanel");
            //runTimeHelper.ShowGraphicSettingsPanel();
        });

        BindListener(MainBg_Button, delegate
        {
            Jyx2_UIManager.Instance.HideUI("SystemUIPanel");
        });
    }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            var playerContext = new PlayerContext();
            var firstScene    = new StoryScene();
            var engine        = new StoryEngine(playerContext, firstScene);

            while (engine.StoryStatus != StoryStatus.Ended)
            {
                var currentScene = engine.NextScene();
                while (currentScene.SceneStatus != SceneStatus.Ended)
                {
                    var currentEvent = currentScene.NextEvent();

                    switch (currentEvent)
                    {
                    case NarrativeEvent _:
                        var narrativeEvent = (NarrativeEvent)currentEvent;
                        foreach (var narrativeResult in narrativeEvent.PlayEvent())
                        {
                            Console.WriteLine(narrativeResult.Text);
                        }

                        break;

                    case ChoiceEvent _:
                        var choiceEvent = (ChoiceEvent)currentEvent;
                        Console.WriteLine("Waiting for player choice");
                        // TODO: have a foreach with index ?
                        for (var i = 0; i < choiceEvent.Choices.Count(); i++)
                        {
                            var choice = choiceEvent.Choices[i];
                            Console.WriteLine("{0}. {1}", i, choice.Text);
                        }

                        var input    = Console.ReadLine();
                        var intInput = short.Parse(input ?? throw new InvalidOperationException());
                        if (intInput > choiceEvent.Choices.Count)
                        {
                            throw new ArgumentOutOfRangeException("Choice not available !");
                        }

                        choiceEvent.Choose(choiceEvent.Choices[intInput], playerContext);
                        break;

                    case EndEvent _:
                        Console.WriteLine("Scene Ended");
                        break;

                    default:
                        throw new InvalidCastException("unexpected child class");
                    }
                }
            }

            Console.WriteLine("Story Ended");
        }
Ejemplo n.º 3
0
 public void OnClickedSaveItem(int index)
 {
     if (savePanelMode == SavePanelMode.New)
     {
         OnNewGame();
     }
     else if (savePanelMode == SavePanelMode.Load)
     {
         StoryEngine.DoLoadGame(index);
     }
     m_savePanel.SetActive(false);
 }
Ejemplo n.º 4
0
 public void OnClickedSaveItem(int index)
 {
     if (savePanelMode == SavePanelMode.Save)
     {
         var levelMaster = FindObjectOfType <LevelMaster>();
         levelMaster.OnManuelSave(index);
     }
     else if (savePanelMode == SavePanelMode.Load)
     {
         StoryEngine.DoLoadGame(index);
     }
     SwitchToSelectionPanel(true);
 }
Ejemplo n.º 5
0
        public OpenWorldGameMode(ViewportAdapter viewPort, IPossibleMovements possibleMovements, string worldName, EntityManager entityManager, StoryEngine storyEngine, EventHandler clickEvent) : base(clickEvent)
        {
            _entityManager      = entityManager;
            EntityRenderersDict = new Dictionary <Entity, AbstractEntityRenderer>();
            _possibleMovements  = possibleMovements;
            _content            = ContentManagerFactory.RequestContentManager();
            RenderList          = new List <IRenderable>();
            Map = _content.Load <TiledMap>($"TopDownRpg/{worldName}");
            var graphics = StaticServiceLocator.GetService <GraphicsDevice>();

            _mapRenderer = new FullMapRenderer(graphics);
            _mapRenderer.SwapMap(Map);
            _tileSize     = new Vector2(Map.TileWidth, Map.TileHeight);
            _moverManager = new MoverManager();
            var collisionSystem = new CompositeAbstractCollisionSystem(_possibleMovements);

            _expiringSpatialHash = new ExpiringSpatialHashCollisionSystem <Entity>(_possibleMovements);
            _spatialHashMover    = new SpatialHashMoverManager <Entity>(collisionSystem, _expiringSpatialHash);
            AddPlayer();
            var entityController = EntityControllerFactory.AddEntityController(PlayerEntity.Instance, _possibleMovements, _moverManager);
            var texture          = _content.Load <Texture2D>("TopDownRpg/Path");
            var endTexture       = _content.Load <Texture2D>("TopDownRpg/BluePathEnd");

            collisionSystem.AddCollisionSystem(new TiledCollisionSystem(_possibleMovements, Map, "Collision-Layer"));
            collisionSystem.AddCollisionSystem(_expiringSpatialHash);
            CollisionSystem = collisionSystem;
            AddClickController(PlayerEntity.Instance);
            PathRenderer = new PathRenderer(_moverManager, PlayerEntity.Instance, texture, endTexture, _tileSize.ToPoint(), Map.Width, Map.Height);
            UpdateList.Add(_expiringSpatialHash);
            UpdateList.Add(entityController);
            UpdateList.Add(_spatialHashMover);
            UpdateList.Add(_moverManager);
            CameraTracker = CameraTrackerFactory.CreateTracker(viewPort, EntityRenderersDict[PlayerEntity.Instance], Map);
            UpdateList.Add(CameraTracker);
            LoadEntities();
            var dialogFont = _content.Load <SpriteFont>("dialog");
            var settings   = StaticServiceLocator.GetService <IControllerSettings>();

            DialogBox = new EntityStoryBoxDialog(ScreenSize.Size, dialogFont, settings.GamePadEnabled);
            GuiManager.AddGuiLayer(DialogBox);
            storyEngine.LoadWorld(AddEntity, RemoveEntity, CollisionSystem.CheckMovementCollision, worldName);
            InteractEvent += (sender, args) =>
            {
                var facingDirection = PlayerEntity.Instance.FacingDirection;
                var interactTarget  = (PlayerEntity.Instance.Position + facingDirection).ToPoint();
                Interact(interactTarget);
            };
            AddInteractionController();
            CameraController.AddCameraZoomController(CameraTracker, ClickController);
            CameraController.AddCameraMovementController(CameraTracker, ClickController);
        }
Ejemplo n.º 6
0
 private void Awake()
 {
     Instance = this;
 }