public override void OnStart(Entity entity)
        {
            var playerState = StaticStates.Get <PlayerState>();

            playerState.CutsceneControlLock = false;
            ActionStatus = ActionStatus.Succeeded;
        }
Exemplo n.º 2
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);
                }
            }
        }
Exemplo n.º 3
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();
            }
        }
Exemplo n.º 4
0
        public void OnFrame()
        {
            var cursorState = StaticStates.Get <CursorState>();

            HighlightEligibleUnderCursor(cursorState);
            HandleMouseClicks(cursorState);
        }
Exemplo n.º 5
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();
        }
        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;
        }
Exemplo n.º 7
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);
        }
Exemplo n.º 8
0
 public void Tick()
 {
     if (StaticStates.Get <GameModeState>().GameMode == GameMode.Play)
     {
         Flood();
     }
 }
Exemplo n.º 9
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);
                }
            }
        }
Exemplo n.º 10
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);
        }
Exemplo n.º 11
0
 public void OnEntityAdded(Entity entity)
 {
     if (entity.GetState <PrefabState>().PrefabName == "ReceiveSpot")
     {
         StaticStates.Get <BarEntities>().ReceiveSpot = entity;
     }
 }
Exemplo n.º 12
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);
        }
Exemplo n.º 13
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);
        }
Exemplo n.º 14
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;
 }
Exemplo n.º 15
0
 private Action TolstoyAsked(DialogueOutcome outcome)
 {
     return(() =>
     {
         StaticStates.Get <PlayerDecisionsState>().TolstoyAskedToMakeDrink = true;
         EndConversation(outcome).Invoke();
     });
 }
Exemplo n.º 16
0
        public void OnEndInit(List <Entity> allPeople)
        {
            if (GameSettings.DisableTutorial)
            {
                return;
            }

            StaticStates.Get <DayPhaseState>().SetDayPhase(DayPhase.Morning);
        }
Exemplo n.º 17
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));
     }
 }
        //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 OnFrame(List <Entity> matchingEntities)
 {
     if (playerState == null)
     {
         playerState = StaticStates.Get <PlayerState>();
         return;
     }
     playerPathfindingState.IsActive = playerState.CutsceneControlLock || StaticStates.Get <DayPhaseState>().CurrentDayPhase == DayPhase.Open;
 }
Exemplo n.º 20
0
        public override void OnStart(Entity entity)
        {
            var dayPhaseState = StaticStates.Get <DayPhaseState>();

            if (dayPhaseState.CurrentDayPhase == DayPhase.Open)
            {
                DayDirectorSystem.Instance.RequestIncrementDayPhase();
            }
            ActionStatus = ActionStatus.Succeeded;
        }
Exemplo n.º 21
0
 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;
 }
Exemplo n.º 22
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);
        }
Exemplo n.º 23
0
        public void OnInit()
        {
            time        = StaticStates.Get <TimeState>();
            playerState = StaticStates.Get <PlayerState>();
            player      = playerState.Player;

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

            dayPhase.DayPhaseChangedTo += DayPhaseChangedTo;
        }
Exemplo n.º 24
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));
        }
Exemplo n.º 25
0
 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);
     }
 }
Exemplo n.º 26
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();
                });
            }
Exemplo n.º 27
0
        public static List <EntityActionPair> DayTwoState()
        {
            var startSequences = new List <EntityActionPair>();

            if (StaticStates.Get <PlayerDecisionsState>().TolstoyAskedToMakeDrink)
            {
                var ellie = EntityStateSystem.Instance.GetEntityWithName(NPCS.Ellie.Name);
                startSequences.Add(new EntityActionPair(ellie, EllieAskForDrink(ellie)));
            }

            return(startSequences);
        }
Exemplo n.º 28
0
        public void OnInit()
        {
            EventSystem.StartDrinkMakingEvent += OnStartMakingDrink;
            EventSystem.OnClickedEvent        += OnClickInteraction;
            EventSystem.EndDrinkMakingEvent   += StopMakingDrink;

            playerState     = StaticStates.Get <PlayerState>();
            player          = playerState.Player;
            playerInventory = player.GetState <InventoryState>();

            dayPhase = StaticStates.Get <DayPhaseState>();
        }
        private static IEnumerable <Entity> CurrentHeirarchy()
        {
            var    heirarchy = new List <Entity>();
            Entity current   = StaticStates.Get <ActiveEntityState>().ActiveEntity;

            do
            {
                heirarchy.Add(current);
                current = current.GetState <PhysicalState>().ParentEntity;
            } while (current != null);
            return(heirarchy);
        }
        public void Update()
        {
            if (Input.GetKeyDown(KeyCode.P))
            {
                StaticStates.Get <GameModeState>().SetGameMode(GameMode.Play);
            }

            if (Input.GetKeyDown(KeyCode.L))
            {
                StaticStates.Get <GameModeState>().SetGameMode(GameMode.Design);
            }
        }