Exemple #1
0
 public void Tick()
 {
     if (StaticStates.Get <GameModeState>().GameMode == GameMode.Play)
     {
         Flood();
     }
 }
Exemple #2
0
        public void StartGame()
        {
            GameSettings.IsDebugOn          = Debug.isDebugBuild && IsDebugOn;
            GameSettings.SkipFirstDayFadein = SkipFirstDayFadein;
            GameSettings.DisableTutorial    = DisableTutorial;

            entitySystem = new EntityStateSystem();

            //StaticStates
            StaticStates.Add(new DayPhaseState(DayPhase.Morning));
            StaticStates.Add(new TimeState(Constants.GameStartTime));
            StaticStates.Add(new CursorState(null, new SerializableVector3()));
            StaticStates.Add(new MoneyState(Constants.StartingMoney));
            StaticStates.Add(new PlayerDecisionsState());
            StaticStates.Add(new OutcomeTrackerState());
            StaticStates.Add(new PaymentTrackerState());

            //Debug
            entitySystem.AddSystem(new DebugControlsSystem());
            entitySystem.AddSystem(new EntityTooltipSystem());

            //Init
            entitySystem.AddSystem(new WaypointSystem());
            entitySystem.AddSystem(new TransformSystem());
            entitySystem.AddSystem(new SpawningSystem());
            entitySystem.AddSystem(new InitVisualizersSystem());

            //Camera
            entitySystem.AddSystem(new CameraSystem());

            //Game
            entitySystem.AddSystem(new TimeSystem());

            entitySystem.AddSystem(new PausingSystem());
            entitySystem.AddSystem(new PathfindingSystem());
            entitySystem.AddSystem(new CharacterControllerSystem());
            entitySystem.AddSystem(new DrinkMakingSystem());
            entitySystem.AddSystem(new InputResponseSystem());
            entitySystem.AddSystem(new DialogueSystem());
            entitySystem.AddSystem(new HierarchyManipulationSystem()); //Must run before VisibleSlotSystem
            entitySystem.AddSystem(new VisibleSlotSystem());
            entitySystem.AddSystem(new ItemStackSystem());
            entitySystem.AddSystem(new BarQueueSystem());
            entitySystem.AddSystem(new BarEntitiesSystem());

            //NPC/AI
            entitySystem.AddSystem(new ActionManagerSystem());
            entitySystem.AddSystem(new DayDirectorSystem());

            //Input - Ordering of systems important here.
            entitySystem.AddSystem(new CursorSystem());
            entitySystem.AddSystem(new InteractionSystem());
            entitySystem.AddSystem(new EntitySelectorSystem());

            //GameStart
            entitySystem.AddSystem(new GameSetupSystem());

            entitySystem.Init();
            GameStarted = true;
        }
        public override void OnStart(Entity entity)
        {
            var playerState = StaticStates.Get <PlayerState>();

            playerState.CutsceneControlLock = false;
            ActionStatus = ActionStatus.Succeeded;
        }
Exemple #4
0
        public void Update()
        {
            if (!GameRunner.Instance.GameStarted)
            {
                return;
            }

            if (timeState == null)
            {
                timeState = StaticStates.Get <TimeState>();
            }

            if (dayPhase == null)
            {
                dayPhase = StaticStates.Get <DayPhaseState>();
            }

            if (timeState == null || dayPhase == null)
            {
                return;
            }

            Day.text = string.Format(DayText, timeState.GameTime.GetDay());

            if (dayPhase.CurrentDayPhase == DayPhase.Open)
            {
                Time.text = string.Format(TimeText, timeState.GameTime.GetHour(), timeState.GameTime.GetMinute());
            }
            else
            {
                Time.text = dayPhase.CurrentDayPhase.ToString();
            }
        }
Exemple #5
0
        public void Update()
        {
            var activeEntity    = StaticStates.Get <ActiveEntityState>().ActiveEntity;
            var selectedGrid    = StaticStates.Get <SelectedState>().Grid;
            var hoveredEntities = activeEntity.GetState <PhysicalState>().GetEntitiesAtGrid(selectedGrid);

            UpdateHoverTime(selectedGrid);
            CleanPreviousTooltips();

            if (hoverTime > TooltipTime)
            {
                TooltipRoot.GetComponent <RectTransform>().transform.position = Input.mousePosition;

                foreach (var entity in hoveredEntities)
                {
                    var tooltip = Instantiate(TooltipWindow);
                    tooltip.GetComponent <RectTransform>().SetParent(TooltipRoot.transform);
                    var textComponent = tooltip.GetComponentInChildren <Text>();
                    textComponent.text = TooltipMessage(entity);
                }

                MatchWidths();

                foreach (Transform child in TooltipRoot.transform)
                {
                    child.gameObject.SetActive(true);
                }
            }
        }
Exemple #6
0
        public void RequestIncrementDayPhase()
        {
            if (doingPhaseChange)
            {
                Debug.Log("Unable to increment day phase as we're already in the middle of incrementing the day phase.");
                return;
            }
            doingPhaseChange = true;
            EntityStateSystem.Instance.Pause();

            var nextDayPhase = StaticStates.Get <DayPhaseState>().GetNextDayPhase();
            var isEndOfDay   = nextDayPhase == DayPhase.Morning;
            var fadeTime     = isEndOfDay ? 12.0f : 6.0f;

            Interface.Instance.BlackFader.FadeToBlack(fadeTime, GetFadeTitle(nextDayPhase), () =>
            {
                ResetNPCs();
                ResetBarStateAndDialogues();
                WaypointSystem.Instance.ClearAllWaypoints();
                SetLighting(nextDayPhase);
                StaticStates.Get <DayPhaseState>().IncrementDayPhase();
                if (isEndOfDay)
                {
                    StaticStates.Get <OutcomeTrackerState>().ClearOutcomes();
                    StaticStates.Get <PaymentTrackerState>().ClearOutcomes();
                }
                EntityStateSystem.Instance.Resume();
                doingPhaseChange = false;
            },
                                                      fadeIn: true,
                                                      endOfDay: isEndOfDay);
        }
Exemple #7
0
        public void Tick(List <Entity> matchingEntities)
        {
            //TODO: Build into system predicates.
            if (StaticStates.Get <GameModeState>().GameMode == GameMode.Design)
            {
                return;
            }

            Profiler.BeginSample("SubstanceSystem");
            foreach (var substanceEntity in matchingEntities)
            {
                if (IsUnobstructed(substanceEntity))
                {
                    foreach (SubstanceType substance in Enum.GetValues(typeof(SubstanceType)))
                    {
                        Profiler.BeginSample("SubstanceSystem-GetNeigbours");
                        var neighbours      = network.NeighboursInclusive(substanceEntity);
                        var validNeighbours = neighbours.Where(IsUnobstructed).ToList();
                        Profiler.EndSample();
                        Profiler.BeginSample("SubstanceSystem-CalcNewValuesAndApply");
                        var averageValue = validNeighbours.Sum(entity => entity.GetState <SubstanceNetworkState>().GetSubstance(substance)) / validNeighbours.Count;
                        foreach (var neighbour in validNeighbours)
                        {
                            neighbour.GetState <SubstanceNetworkState>().UpdateSubstance(substance, averageValue);
                        }
                        Profiler.EndSample();
                    }
                }
            }
            Profiler.EndSample();
        }
Exemple #8
0
        public void OnFrame()
        {
            var cursorState = StaticStates.Get <CursorState>();

            HighlightEligibleUnderCursor(cursorState);
            HandleMouseClicks(cursorState);
        }
Exemple #9
0
        public static List <EntityActionPair> DayTwoNight()
        {
            var actions = new List <EntityActionPair>();

            var tolstoy = EntityStateSystem.Instance.GetEntityWithName(NPCS.Tolstoy.Name);
            var ellie   = EntityStateSystem.Instance.GetEntityWithName(NPCS.Ellie.Name);

            var tolstoySequence = new ActionSequence("Tolstoy night two");
            var ellieSequence   = new ActionSequence("Ellie night two");

            if (StaticStates.Get <PlayerDecisionsState>().GaveEllieTolstoysDrink)
            {
                tolstoySequence.Add(new TeleportAction(Locations.SitDownPoint5()));
                tolstoySequence.Add(new SetReactiveConversationAction(new TosltoyNightTwoSuccess()));

                ellieSequence.Add(new TeleportAction(Locations.SitDownPoint6()));
                ellieSequence.Add(new SetReactiveConversationAction(new EllieNightTwoSuccess()));
            }
            else
            {
                tolstoySequence.Add(new TeleportAction(Locations.SitDownPoint1()));
                tolstoySequence.Add(new SetReactiveConversationAction(new TolstoyNightTwoFailure()));

                ellieSequence.Add(new TeleportAction(Locations.SitDownPoint3()));
                ellieSequence.Add(new SetReactiveConversationAction(new EllieNightTwoFailure(ellie.GetState <RelationshipState>()), ellie));
            }

            tolstoySequence.Add(new TriggerAnimationAction(Util.AnimationEvent.SittingStartTrigger));
            actions.Add(new EntityActionPair(tolstoy, tolstoySequence));

            ellieSequence.Add(new TriggerAnimationAction(Util.AnimationEvent.SittingStartTrigger));
            ActionManagerSystem.Instance.QueueAction(ellie, ellieSequence);

            return(actions);
        }
Exemple #10
0
        public static List <EntityActionPair> DayOneMorning()
        {
            var actions = new List <EntityActionPair>();

            var tolstoy = EntityStateSystem.Instance.GetEntityWithName(NPCS.Tolstoy.Name);
            var ellie   = EntityStateSystem.Instance.GetEntityWithName(NPCS.Ellie.Name);

            //Ellie
            var ellieSequence = new ActionSequence("Ellie morning");

            ellieSequence.Add(new TeleportAction(Locations.SitDownPoint1()));
            ellieSequence.Add(new SetReactiveConversationAction(new EllieMorningOne(), ellie));
            ellieSequence.Add(CommonActions.SitDownLoop());
            ActionManagerSystem.Instance.QueueAction(ellie, ellieSequence);

            //Tolstoy
            var tolstoySequence = new ActionSequence("Tolstoy morning");

            tolstoySequence.Add(new TeleportAction(Locations.SitDownPoint2()));
            tolstoySequence.Add(new SetReactiveConversationAction(new TolstoyMorningOne(), tolstoy));
            tolstoySequence.Add(new TriggerAnimationAction(Util.AnimationEvent.SittingStartTrigger));
            tolstoySequence.Add(CommonActions.WaitForDrink(tolstoy, "None", new DrinkOrders.AlwaysSucceedsDrinkOrder(), 99999));
            tolstoySequence.Add(new UpdateMoodAction(Mood.Happy));
            tolstoySequence.Add(new ConversationAction(new TolstoyMorningGivenDrink()));
            tolstoySequence.Add(new SetReactiveConversationAction(new TolstoyMorningAfterDrink()));
            tolstoySequence.Add(new CallbackAction(() =>
            {
                StaticStates.Get <PlayerDecisionsState>().GaveTolstoyDrink = true;
                StaticStates.Get <OutcomeTrackerState>().AddOutcome("Tolstoy's was suprised by your kindness.");
            }));
            tolstoySequence.Add(CommonActions.SitDownLoop());
            ActionManagerSystem.Instance.QueueAction(tolstoy, tolstoySequence);

            return(actions);
        }
        private Entity SpawnPlayer(Vector3 position)
        {
            var player = entitySystem.CreateEntity(new List <IState>
            {
                new PrefabState(Prefabs.Player),
                new IsPlayerState(),
                new InventoryState(),
                new VisibleSlotState(),
                new PositionState(position),
                new RotationState(Quaternion.identity),
                new PathfindingState(null, null),
                new ActionBlackboardState(null),
                //Warning: Changing 'You' to something else will break stuff.
                new NameState("You", 2.0f),
                new DialogueOutcomeState(),
                new PersonAnimationState(),
                new ClothingState(ClothingTopType.BartenderTop, ClothingBottomType.BartenderBottom),
                new HairState(HairType.Hair_Bartender),
                new FaceState(FaceType.Face_Bartender),
                new IsPersonState(),
                new InteractiveState()
            }, false);

            StaticStates.Add(new PlayerState(player, !GameSettings.DisableTutorial));
            return(player);
        }
Exemple #12
0
        public void Awake()
        {
            entitySystem = new EntityStateSystem();

            Console.RegisterCommand("showEntity", "showEntity 1337", "returns all states for an entity",
                                    command =>
            {
                var args  = Console.SplitParameters(command);
                var debug = entitySystem.DebugEntity(Convert.ToInt32(args[1]));
                Console.WriteLine(debug);
            }
                                    );

            //TODO: this should be via the entity System. Fix this before save load.
            StaticStates.Add(new WorldEntityState(entitySystem.BuildEntity(new List <IState>())));
            StaticStates.Add(new ActiveEntityState(entitySystem.BuildEntity(new List <IState>())));
            StaticStates.Add(new GameModeState(GameMode.Design));
            StaticStates.Add(new EntityLibraryState(InitialBuildableEntities.BuildableEntityLibrary));
            StaticStates.Add(new SelectedState());

            entitySystem.AddSystem(new WorldInitSystem());
            entitySystem.AddSystem(new GlobalControlsSystem());
            entitySystem.AddSystem(new PlayerEntityModificationSystem());
            entitySystem.AddSystem(new EngineSystem());
            entitySystem.AddSystem(new SubstanceNetworkSystem());
            entitySystem.AddSystem(new EntityLibrarySystem());
            entitySystem.AddSystem(new SaveLoadSystem());
            entitySystem.AddSystem(new CrewMovementSystem());
            entitySystem.AddSystem(new CrewHealthSystem());
            entitySystem.AddSystem(new SeaSystem());

            entitySystem.Init();
            StartCoroutine(Ticker());
        }
 public void OnEntityAdded(Entity entity)
 {
     if (entity.GetState <PrefabState>().PrefabName == "ReceiveSpot")
     {
         StaticStates.Get <BarEntities>().ReceiveSpot = entity;
     }
 }
        public void Update()
        {
            Clear();

            var activeEntity = StaticStates.Get <ActiveEntityState>().ActiveEntity;

            Profiler.BeginSample("Component Renderer outer");
            RenderOuterComponent(activeEntity);
            Profiler.EndSample();

            Profiler.BeginSample("Component Renderer inner");
            RenderInnerComponents(activeEntity);
            Profiler.EndSample();

            if (!activeEntity.GetState <PhysicalState>().IsRoot())
            {
                var entitiesAtThisEntitiesLevel = activeEntity.GetState <PhysicalState>().ParentEntity.GetState <PhysicalState>().ChildEntities;
                foreach (var entity in entitiesAtThisEntitiesLevel)
                {
                    RenderOuterComponent(entity, 0.4f);
                    RenderInnerComponents(entity, 0.4f);
                }
            }

            if (activeEntity != lastRenderedEntity)
            {
                CenterCamera(activeEntity);
            }

            lastRenderedEntity = activeEntity;
        }
Exemple #15
0
        /**
         *      Day 2
         * */

        #region Day 2 - Morning
        public static ActionSequence InspectorQuestions(Entity security)
        {
            var questionTime = new ActionSequence("InspectorQuestions");

            questionTime.Add(StaticStates.Get <PlayerDecisionsState>().AcceptedDrugPushersOffer
                ? CommonActions.TalkToPlayer(new InspectorSuspicious())
                : CommonActions.TalkToPlayer(new InspectorNice()));
            questionTime.Add(new DialogueBranchAction(new Dictionary <DialogueOutcome, Action>
            {
                {
                    DialogueOutcome.Agree, () =>
                    {
                        var sequence = new ActionSequence("Help inspector.");
                        sequence.Add(new ConversationAction(new NoResponseConversation("Thanks for the help! Glad I could count on you to keep the ship safe.", DialogueOutcome.Agree)));
                        sequence.Add(new UpdateMoodAction(Mood.Happy));

                        ActionManagerSystem.Instance.AddActionToFrontOfQueueForEntity(security, sequence);
                        StaticStates.Get <PlayerDecisionsState>().ToldInspectorAboutDrugPusher = true;
                    }
                },
                {
                    DialogueOutcome.Disagree, () =>
                    {
                        var sequence = new ActionSequence("Didn't help inspector.");
                        sequence.Add(new ConversationAction(new NoResponseConversation("Thanks for your time. Let me know if you see anything suspicious.", DialogueOutcome.Default)));

                        ActionManagerSystem.Instance.AddActionToFrontOfQueueForEntity(security, sequence);
                        StaticStates.Get <PlayerDecisionsState>().ToldInspectorAboutDrugPusher = false;
                    }
                }
            }));
            questionTime.Add(new LeaveBarAction());
            return(questionTime);
        }
Exemple #16
0
        public void OnFrame()
        {
            var cursorState    = StaticStates.Get <CursorState>();
            var selectedEntity = !GameSettings.IsDebugOn ? cursorState.SelectedEntity : cursorState.DebugEntity;

            UpdateHoverTime(selectedEntity);
            CleanPreviousTooltips();

            tooltipRoot.GetComponent <RectTransform>().transform.position = Input.mousePosition;

            if (hoverTime > TooltipTime && selectedEntity != null)
            {
                if (!GameSettings.IsDebugOn && !selectedEntity.HasState <TooltipState>())
                {
                    return;
                }

                var tooltip = UnityEngine.Object.Instantiate(tooltipWindow);
                tooltip.GetComponent <RectTransform>().SetParent(tooltipRoot.transform);
                var textComponent = tooltip.GetComponentInChildren <Text>();
                textComponent.text = TooltipMessage(selectedEntity);

                MatchWidths();

                foreach (Transform child in tooltipRoot.transform)
                {
                    child.gameObject.SetActive(true);
                }
            }
        }
Exemple #17
0
 public void OnEndInit(List <Entity> allPeople)
 {
     dayPhase                    = StaticStates.Get <DayPhaseState>();
     time                        = StaticStates.Get <TimeState>();
     people                      = allPeople;
     hallwayWalkers              = EntityQueries.GetNPCSWithName(allPeople, NPCName.Expendable);
     dayPhase.DayPhaseChangedTo += OnDayPhaseChanged;
 }
Exemple #18
0
 private Action TolstoyAsked(DialogueOutcome outcome)
 {
     return(() =>
     {
         StaticStates.Get <PlayerDecisionsState>().TolstoyAskedToMakeDrink = true;
         EndConversation(outcome).Invoke();
     });
 }
 public void OnFrame(List <Entity> matchingEntities)
 {
     if (playerState == null)
     {
         playerState = StaticStates.Get <PlayerState>();
         return;
     }
     playerPathfindingState.IsActive = playerState.CutsceneControlLock || StaticStates.Get <DayPhaseState>().CurrentDayPhase == DayPhase.Open;
 }
        public void OnEndInit(List <Entity> allPeople)
        {
            if (GameSettings.DisableTutorial)
            {
                return;
            }

            StaticStates.Get <DayPhaseState>().SetDayPhase(DayPhase.Morning);
        }
        //TODO: Use custom "toString" style pattern here.
        private void UpdateComponentDetails()
        {
            var selectedState = StaticStates.Get <SelectedState>();

            SelectedComponentName.text = string.Format(
                "Selected Grid: {0}",
                selectedState.Grid
                );
        }
        public void OnInit()
        {
            StaticStates.Add(new BarEntities());
            var player = SpawnPlayer(new Vector3(9.5f, 1.2f, 0.6f));

            SpawnCamera(new Vector3(12.07f, 15.9f, 0.0f), Quaternion.Euler(48, -90, 0), player);
            SpawnPeople(entitySystem);
            SpawnEntitiesFromBlueprints();
        }
Exemple #23
0
 protected override void StartConversation(string converstationInitiator)
 {
     if (StaticStates.Get <PlayerDecisionsState>().AcceptedDrugPushersOffer)
     {
         DialogueSystem.Instance.StartDialogue(converstationInitiator);
         DialogueSystem.Instance.WriteNPCLine("Pretty good day today. Here is your cut.");
         DialogueSystem.Instance.WritePlayerChoiceLine("Thanks.", EndConversation(DialogueOutcome.Nice));
     }
 }
 public override void OnStart(Entity entity)
 {
     if (moneyDelta > 0)
     {
         StandardSoundPlayer.Instance.PlaySfx(SFXEvent.Kaching);
     }
     StaticStates.Get <PaymentTrackerState>().AddPayment(moneyDelta, paymentType);
     StaticStates.Get <MoneyState>().ModifyMoney(moneyDelta);
     ActionStatus = ActionStatus.Succeeded;
 }
        public void OnInit()
        {
            time        = StaticStates.Get <TimeState>();
            playerState = StaticStates.Get <PlayerState>();
            player      = playerState.Player;

            var dayPhase = StaticStates.Get <DayPhaseState>();

            dayPhase.DayPhaseChangedTo += DayPhaseChangedTo;
        }
Exemple #26
0
        public override void OnStart(Entity entity)
        {
            var dayPhaseState = StaticStates.Get <DayPhaseState>();

            if (dayPhaseState.CurrentDayPhase == DayPhase.Open)
            {
                DayDirectorSystem.Instance.RequestIncrementDayPhase();
            }
            ActionStatus = ActionStatus.Succeeded;
        }
Exemple #27
0
        public static ActionSequence TalkToPlayer(Conversation conversation)
        {
            var player  = StaticStates.Get <PlayerState>().Player;
            var talking = new ActionSequence("TalkToPlayer", isCancellable: false);

            talking.Add(new SetTargetEntityAction(player));
            talking.Add(new GoToMovingEntityAction());
            talking.Add(new ConversationAction(conversation));
            return(talking);
        }
 private static void AddIngredientToDrink(Entity drink, Entity dispenser)
 {
     if (drink != null && drink.HasState <DrinkState>() && drink.GetState <DrinkState>().GetTotalDrinkSize() < Constants.MaxUnitsInDrink)
     {
         var ingredient = dispenser.GetState <DrinkState>().GetContents().Keys.First();
         dispenser.GameObject.GetComponent <OneShotAudioPlayer>().PlayOneShot();
         StaticStates.Get <PaymentTrackerState>().AddPayment(-Constants.IngredientCost, PaymentType.DrinkIngredient);
         StaticStates.Get <MoneyState>().ModifyMoney(-Constants.IngredientCost);
         drink.GetState <DrinkState>().ChangeIngredientAmount(ingredient, 1);
     }
 }
Exemple #29
0
        private static ActionSequence DrugPusherDrinkTest(Entity drugPusher)
        {
            var failureConversations = StaticStates.Get <PlayerDecisionsState>().AcceptedDrugPushersOffer ? drugPusherFailureLinesAccepted : drugPusherFailureLinesRejected;
            var successConversations = StaticStates.Get <PlayerDecisionsState>().AcceptedDrugPushersOffer ? drugPusherSuccessLinesAccepted : drugPusherSuccessLinesRejected;
            var betweenDrinks        = new List <GameAction> {
                CommonActions.TalkToBarPatron(), CommonActions.TalkToBarPatron(), CommonActions.TalkToBarPatron()
            };
            var afterSuccess = CommonActions.TalkToBarPatronsLoop();

            return(DrinkTest(0, 3, drugPusher, failureConversations, successConversations, betweenDrinks, afterSuccess));
        }
Exemple #30
0
            private Action ToldAboutTolstoy()
            {
                return(() =>
                {
                    var ellie = EntityStateSystem.Instance.GetEntityWithName(NPCS.Ellie.Name);
                    ellie.GetState <RelationshipState>().PlayerOpinion++;

                    StaticStates.Get <PlayerDecisionsState>().GaveEllieTolstoysDrink = true;
                    EndConversation(DialogueOutcome.Nice).Invoke();
                });
            }