예제 #1
0
        private void HandleOption(int option)
        {
            CalendarModel model    = AmbitionApp.GetModel <CalendarModel>();
            IncidentVO    incident = model.Incident;

            if (incident != null)
            {
                MomentVO   moment    = model.Moment;
                MomentVO[] neighbors = incident.GetNeighbors(moment);
                if (option < neighbors.Length)
                {
                    TransitionVO[] transitions = model.Incident.GetLinkData(moment);

                    if (option < transitions.Length) // This should be a tautology, but whatever
                    {
                        Array.ForEach(transitions[option].Rewards, AmbitionApp.SendMessage);
                    }

                    model.Moment = neighbors[option];
                }
                else
                {
                    model.Moment = null;
                }
            }
            Activate();
        }
예제 #2
0
        public override void OnEnter()
        {
            IncidentModel model  = AmbitionApp.GetModel <IncidentModel>();
            MomentVO      moment = model.UpdateMoment();

            AmbitionApp.GetModel <LocalizationModel>().SetMoment(moment);
            AmbitionApp.SendMessage(moment);
            AmbitionApp.SendMessage(moment.Rewards);

            TransitionVO[] links = model.Incident.GetLinks(moment);
            AmbitionApp.SendMessage(links);
        }
예제 #3
0
        public override void OnEnterState()
        {
            CalendarModel model  = AmbitionApp.GetModel <CalendarModel>();
            MomentVO      moment = model.Moment;

            if (moment != null)
            {
                int index = model.Incident.GetNodeIndex(moment);
                AmbitionApp.SendMessage(moment.Rewards);
                if (index >= 0)
                {
                    AmbitionApp.SendMessage(model.Incident.GetLinkData(index));
                }
            }
        }
예제 #4
0
        /*
         * private void HandleIncident(IncidentVO incident)
         * {
         *  if (incident != null) titleText.text = incident.Name;
         *  print("Incident Name = " + incident.Name);
         * }*/

        private void HandleMoment(MomentVO moment)
        {
            if (moment != null)
            {
                descriptionText.text = moment.Text;
                if (moment.Background != null)
                {
                    _background.sprite = moment.Background;
                }
                Character1.ID   = moment.Character1.AvatarID;
                Character1.Pose = moment.Character1.Pose;
                Character2.ID   = moment.Character2.AvatarID;
                Character2.Pose = moment.Character2.Pose;

                if (moment.Music.Name.Length > 0)
                {
                    AmbitionApp.SendMessage(AudioMessages.PLAY_MUSIC, moment.Music);
                }
                if (moment.AmbientSFX.Name.Length > 0)
                {
                    AmbitionApp.SendMessage(AudioMessages.PLAY_AMBIENTSFX, moment.AmbientSFX);
                }
                if (moment.OneShotSFX.Name.Length > 0)
                {
                    AmbitionApp.SendMessage(AudioMessages.PLAY_ONESHOTSFX, moment.OneShotSFX);
                }

                SpeakerName.enabled = (moment.Speaker != SpeakerType.None);
                switch (moment.Speaker)
                {
                case SpeakerType.Player:
                    SpeakerName.text = AmbitionApp.GetModel <GameModel>().PlayerName;
                    break;

                case SpeakerType.Character1:
                    SpeakerName.text = moment.Character1.Name;
                    break;

                case SpeakerType.Character2:
                    SpeakerName.text = moment.Character2.Name;
                    break;
                }
            }
        }
예제 #5
0
        public void SetMoment(MomentVO moment)
        {
            Substitutions[LocalizationConsts.CHARACTER_1] = moment?.Character1.Name;
            Substitutions[LocalizationConsts.CHARACTER_2] = moment?.Character2.Name;
            switch (moment?.Speaker)
            {
            case SpeakerType.Character1:
                Substitutions[LocalizationConsts.SPEAKER] = moment.Character1.Name;
                break;

            case SpeakerType.Character2:
                Substitutions[LocalizationConsts.SPEAKER] = moment.Character2.Name;
                break;

            case SpeakerType.Player:
                Substitutions[LocalizationConsts.SPEAKER] = Substitutions[LocalizationConsts.PLAYER_NAME];
                break;

            default:
                Substitutions[LocalizationConsts.SPEAKER] = "";
                break;
            }
        }
예제 #6
0
        private static List <CommodityVO> TraceRewards(IncidentVO incident, int node, List <CommodityVO> rewards, List <int> traversed)
        {
            if (traversed.Contains(node) || node >= (incident?.Nodes?.Length ?? 0))
            {
                return(rewards);                                                                    // Prevent circular references
            }
            MomentVO    moment = incident.Nodes[node];
            CommodityVO item;

            traversed.Add(node);
            if (moment.Rewards != null)
            {
                foreach (CommodityVO reward in moment.Rewards)
                {
                    switch (reward.Type)
                    {
                    case CommodityType.Gossip:
                    case CommodityType.Item:
                        rewards.Add(reward.Clone());
                        break;

                    case CommodityType.Livre:
                    case CommodityType.Peril:
                    case CommodityType.Credibility:
                        item = rewards.Find(r => r.Type == reward.Type);
                        if (item == null)
                        {
                            rewards.Add(reward.Clone());
                        }
                        else
                        {
                            item.Value += reward.Value;
                        }
                        break;

                    case CommodityType.Favor:
                        item = rewards.Find(r => r.ID == reward.ID);
                        if (item == null)
                        {
                            rewards.Add(reward.Clone());
                        }
                        else
                        {
                            item.Value += reward.Value;
                        }
                        break;
                    }
                }
            }
            int[] neighbors = incident.GetNeighbors(node);
            if (neighbors.Length == 0)
            {
                return(rewards);
            }


            foreach (int neighbor in neighbors)
            {
                rewards = TraceRewards(incident, neighbor, rewards, new List <int>(traversed));
            }
            return(rewards);
        }
예제 #7
0
 private void HandleMoment(MomentVO moment)
 {
     _animator.SetBool(ACTIVE, moment != null);
 }
예제 #8
0
        private void HandleMoment(MomentVO moment)
        {
            if (_incident == null)
            {
                AmbitionApp.SendMessage(GameMessages.HIDE_HEADER);
            }
            else
            {
                AmbitionApp.SendMessage(GameMessages.SHOW_HEADER, _incident.ID + ".name");
                if (_incident?.Nodes != null && moment != null)
                {
                    int index = Array.IndexOf(_incident.Nodes, moment);
                    if (index >= 0)
                    {
                        descriptionText.text = AmbitionApp.Localize(_incident.ID + ".node." + index.ToString());
                        if (moment.Background != null && !moment.Background.Equals(_background.sprite))
                        {
                            if (index > 0)
                            {
                                StopAllCoroutines();
                                StartCoroutine(SwapBG(moment.Background));
                            }
                            else
                            {
                                _background.sprite = moment.Background;
                            }
                        }
                        Character1.Avatar = Avatars.GetAvatar(moment.Character1.AvatarID);
                        Character1.Pose   = moment.Character1.Pose;
                        Character1.Play(moment.Character1.Motion);
                        Character2.Avatar = Avatars.GetAvatar(moment.Character2.AvatarID);
                        Character2.Pose   = moment.Character2.Pose;
                        Character2.Play(moment.Character2.Motion);

                        AmbitionApp.SendMessage(AudioMessages.PLAY, moment.OneShotSFX);
                        if (moment.Music.Name.Length > 0)
                        {
                            AmbitionApp.SendMessage(AudioMessages.PLAY_MUSIC, moment.Music);
                        }
                        if (moment.AmbientSFX.Name.Length > 0)
                        {
                            AmbitionApp.SendMessage(AudioMessages.PLAY_AMBIENT, moment.AmbientSFX);
                        }

                        SpeakerName.enabled = (moment != null && moment.Speaker != SpeakerType.None);
                        switch (moment.Speaker)
                        {
                        case SpeakerType.Player:
                            SpeakerName.text = AmbitionApp.GetModel <GameModel>().PlayerName;
                            break;

                        case SpeakerType.Character1:
                            SpeakerName.text = moment.Character1.Name;
                            break;

                        case SpeakerType.Character2:
                            SpeakerName.text = moment.Character2.Name;
                            break;
                        }
                    }
                }
            }
        }