Esempio n. 1
0
 //Updates the onscreen list from controller's list
 public void UpdatePlayThroughList()
 {
     if (updateInProgress)
     {
         return;
     }
     if (allPlaythroughs.Count == 0)
     {
         return;
     }
     updateInProgress = true;
     foreach (var item in buttonList)
     {
         if (item == null)
         {
             return;
         }
         Destroy(item.gameObject);
     }
     foreach (var item in allPlaythroughs)
     {
         GameObject btn = Instantiate(Resources.Load("Button") as GameObject, new Vector3(0, 0, 0), Quaternion.identity, playThroughList.transform);
         btn.GetComponentInChildren <Text>().text = "Playthrough " + allPlaythroughs.IndexOf(item).ToString();
         buttonList.Add(btn.GetComponent <Button>());
         btn.GetComponent <Button>().onClick.AddListener(() => SelectPlayThrough(allPlaythroughs.IndexOf(item)));
         Debug.Log("Button with parameter: " + allPlaythroughs.IndexOf(item));
     }
     selectedPlayThrough = allPlaythroughs[0];
     UpdateTexts();
     updateInProgress = false;
 }
Esempio n. 2
0
        public Playthrough AddPlaythrough()
        {
            var playthrough = new Playthrough();

            playthroughs.Add(playthrough);
            return(playthrough);
        }
Esempio n. 3
0
        internal static PlaythroughDeleteViewModel ToDeleteViewModel(Playthrough playthrough)
        {
            var playthroughDeleteViewModel = new PlaythroughDeleteViewModel
            {
                PlayDataID    = playthrough.PlayDataID,
                OrdinalNumber = playthrough.OrdinalNumber
            };

            return(playthroughDeleteViewModel);
        }
Esempio n. 4
0
 internal static UserDashboardEventViewModel FinishedPlaythroughToRecentEvent(Playthrough playthrough)
 {
     return(new UserDashboardEventViewModel
     {
         Type = "Finished",
         Date = (DateTime)playthrough.DateEnd,
         DateString = ((DateTime)playthrough.DateEnd).ToString(EntityConstants.DateFormatString),
         Title = playthrough.PlayData.Game.Title,
         URL = $"../PlayData/Details/{playthrough.PlayData.ID}"
     });
 }
Esempio n. 5
0
 internal static UserDashboardGameViewModel ToGameViewModel(Playthrough playthrough)
 {
     return(new UserDashboardGameViewModel
     {
         PlayDataID = playthrough.PlayDataID,
         OrdinalNumber = playthrough.OrdinalNumber,
         PlaythroughNotes = playthrough.Notes,
         GameID = playthrough.PlayData.GameID,
         GamePlatform = playthrough.PlayData.Game.Platform.ShortName,
         GameTitle = playthrough.PlayData.Game.Title
     });
 }
Esempio n. 6
0
        internal static GamePlaythroughDetailsViewModel ToGameDetailsViewModel(Playthrough playthrough)
        {
            var playtime = new TimeSpan(0, playthrough.PlaytimeInMinutes, 0);

            var ptVM = new GamePlaythroughDetailsViewModel
            {
                PlayDataID    = playthrough.PlayDataID,
                OrdinalNumber = playthrough.OrdinalNumber,
                Status        = playthrough.Status,
                Playtime      = PlaytimeHelper.GetShortPlaytimeString(playtime),
                PlayDates     = PlayDatesHelper.GetPlayDatesString(playthrough.DateStart, playthrough.DateEnd),
                Notes         = playthrough.Notes
            };

            return(ptVM);
        }
Esempio n. 7
0
        internal static Playthrough ToPlaythrough(PlaythroughCreateUpdateViewModel playthroughCreateUpdateViewModel)
        {
            var playtime = new TimeSpan(playthroughCreateUpdateViewModel.PlaytimeDays, playthroughCreateUpdateViewModel.PlaytimeHours, playthroughCreateUpdateViewModel.PlaytimeMinutes, 0);

            var playthrough = new Playthrough
            {
                PlayDataID           = playthroughCreateUpdateViewModel.PlayDataID,
                OrdinalNumber        = (int)playthroughCreateUpdateViewModel.OrdinalNumber,
                PlayStatusID         = playthroughCreateUpdateViewModel.PlayStatusID,
                DateStart            = playthroughCreateUpdateViewModel.DateStart,
                DateEnd              = playthroughCreateUpdateViewModel.DateEnd,
                PlaytimeInMinutes    = (int)playtime.TotalMinutes,
                SideContentCompleted = playthroughCreateUpdateViewModel.SideContentCompleted,
                Notes = playthroughCreateUpdateViewModel.Notes
            };

            return(playthrough);
        }
Esempio n. 8
0
        internal static PlaythroughCreateUpdateViewModel ToUpdateViewModel(Playthrough playthrough, IEnumerable <PlayStatus> playStatusList)
        {
            var playtime = new TimeSpan(0, playthrough.PlaytimeInMinutes, 0);

            var playthroughUpdateViewModel = new PlaythroughCreateUpdateViewModel
            {
                PlayDataID           = playthrough.PlayDataID,
                OrdinalNumber        = playthrough.OrdinalNumber,
                PlayStatusID         = playthrough.PlayStatusID,
                DateStart            = playthrough.DateStart,
                DateEnd              = playthrough.DateEnd,
                PlaytimeDays         = playtime.Days,
                PlaytimeHours        = playtime.Hours,
                PlaytimeMinutes      = playtime.Minutes,
                SideContentCompleted = playthrough.SideContentCompleted,
                Notes = playthrough.Notes
            };

            playthroughUpdateViewModel.PlayStatusSelectList = new SelectList(playStatusList, nameof(PlayStatus.ID), nameof(PlayStatus.Name));

            return(playthroughUpdateViewModel);
        }
    private void Start()
    {
        // Before we do anything, we need to set up Charisma. Put this in your initialisation code. You only need to do this one.
        Playthrough.Setup();

        // The Charisma logger logs events to and from Charisma.
        CharismaLogger.IsActive = showLog;

        // We create the config of our token, based on the settings we have defined in the inspector, here.
        var playthroughTokenParams = new CreatePlaythroughTokenParams(storyId: storyId, storyVersion: storyVersion, apiKey: apiKey);

        // We use these settings to create a play-through token.
        CharismaAPI.CreatePlaythroughToken(tokenParams: playthroughTokenParams, callback: token =>
        {
            // Once we receive the callback with our token, we can create a new conversation.
            CharismaAPI.CreateConversation(token: token, callback: conversationId =>
            {
                // We'll cache our conversation Id since we need this to send replies and other events to Charisma.
                this._conversationId = conversationId;

                // We can now create a new charisma object and pass it our token.
                this._charisma = new Playthrough(token: token);

                // We can now connect to Charisma. Once we receive the ready callback, we can start our play-through.
                _charisma.Connect(onReadyCallback: () =>
                {
                    Debug.Log("Ready!");
                    speechOptions = new SpeechOptions(SpeechOptions.AudioOutput.Buffer, SpeechOptions.Encoding.Ogg);

                    // In the start function, we pass the scene we want to start from, the conversationId we cached earlier, and the speech options from the inspector.
                    _charisma.Start(sceneIndex: startFromScene, conversationId: _conversationId, speechOptions: speechOptions);
                });

                // We can now subscribe to message events from charisma.
                _charisma.OnMessage += (id, message) =>
                {
                    Debug.Log(message);
                    // If the message is a panel-node, we should operate on this data without trying to generate audio or access the text & character data of the node since panel-nodes have neither.
                    if (message.MessageType == MessageType.panel)
                    {
                        CharismaLogger.Log("This is a panel node");

                        // We can't generate speech or access character & text data so we return after we have checked if this is the end of the story.
                        if (message.EndStory)
                        {
                            _charisma.Disconnect();
                        }

                        return;
                    }

                    if (useSpeech)
                    {
                        // Once we have received a message character message, we might want to play the audio. To do this we run the GetClip method and wait for the callback which contains our audio clip, then pass it to the audio player.
                        message.Message.Speech?.Audio.GetClip(options: speechOptions, onAudioGenerated: (clip =>
                        {
                            audioSource.clip = clip;
                            audioSource.Play();
                        }));
                    }

                    text.text = ($"{message.Message.Character?.Name}: {message.Message?.Text}");

                    // If this is the end of the story, we disconnect from Charisma.
                    if (message.EndStory)
                    {
                        _charisma.Disconnect();
                    }
                };
            });
        });

        // Bind the SendPlayerMessage function to the UI button.
        button.onClick.AddListener(call: SendPlayerMessage);
    }
Esempio n. 10
0
        internal static PlayDataPlaythroughDetailsViewModel ToPlayDataDetailsViewModel(Playthrough playthrough)
        {
            var playtime = new TimeSpan(0, playthrough.PlaytimeInMinutes, 0);

            var ptVM = new PlayDataPlaythroughDetailsViewModel
            {
                PlayDataID    = playthrough.PlayDataID,
                OrdinalNumber = playthrough.OrdinalNumber,
                Status        = playthrough.Status,
                Playtime      = PlaytimeHelper.GetLongPlaytimeString(playtime),
                DateStart     = playthrough.DateStart == null ? "Unknown" : ((DateTime)playthrough.DateStart).ToString(EntityConstants.DateFormatString),
                DateEnd       = playthrough.DateEnd == null ? "Unknown" : ((DateTime)playthrough.DateEnd).ToString(EntityConstants.DateFormatString),
                Notes         = playthrough.Notes
            };

            return(ptVM);
        }
Esempio n. 11
0
        /// <summary>
        /// Reads in a save from a file path.
        /// </summary>
        /// <param name="filePath"></param>
        /// <returns></returns>
        public static Save Read(string filePath)
        {
            Save save = new Save();

            byte[]       file   = File.ReadAllBytes(filePath);
            MemoryStream stream = new MemoryStream(file);
            BinaryReader reader = new BinaryReader(stream);

            // The file starts with a 15 byte header. Let's match this.
            //? This may be a version number too, but honestly everyone should be on the newest
            //? version by now.
            byte[] detectedHeader = reader.ReadBytes(Header.Length);
            if (detectedHeader.Intersect(Header).Count() != detectedHeader.Union(Header).Count())
            {
                Console.Error.WriteLine("This is not a valid save file!");
                return(save);
            }

            // The file starts with the character class internal name.
            save.Details = new CharacterDetails(reader);

            // Now we've got skills and proficiencies to count. Borderlands made them the same
            // thing, but I'll make them separate.
            Int32 skillCount = reader.ReadInt32();

            for (Int32 x = 0; x < skillCount; ++x)
            {
                string skillName = reader.BL_ReadString();
                reader.BaseStream.Seek(-skillName.Length - 5, SeekOrigin.Current);
                // Check whether the skill is a proficiency.
                if (skillName.IndexOf("gd_skills_") == 0)
                {
                    // In this case, it's a proficiency.
                    save.Proficiencies.ReadProficiency(reader);
                }
                else
                {
                    save.Skills.ReadSkill(reader);
                }
            }

            // Then there's stuff that no one knows.
            save.Vehicle1Color    = reader.ReadInt32();
            save.Vehicle2Color    = reader.ReadInt32();
            save.UnknownVariable4 = reader.ReadInt32();
            save.UnknownVariable5 = reader.ReadInt32();

            // Now we've got the ammo types.
            Int32 ammoCount = reader.ReadInt32();

            for (Int32 x = 0; x < ammoCount; ++x)
            {
                string   ammoName = reader.BL_ReadString();
                AmmoType type     = AmmoPool.AmmoDefinitions[ammoName];
                save.Ammo[type].InternalName = ammoName;

                //? A sanity check to see if the pool name matches?
                if (save.Ammo[type].PoolInternalName != reader.BL_ReadString())
                {
                    // Panic.
                    Console.Error.WriteLine($"Tried to match expected ammo type {save.Ammo[type].PoolInternalName} but got something else!");
                }

                save.Ammo[type].Ammo         = reader.ReadSingle();
                save.Ammo[type].UpgradeLevel = reader.ReadInt32();
            }

            // Now the items.
            Int32 itemCount = reader.ReadInt32();

            for (Int32 x = 0; x < itemCount; ++x)
            {
                save.Items.Add(new Item(reader));
            }

            // Some slot counters.
            save.BackpackSlots = reader.ReadInt32();
            save.WeaponSlots   = reader.ReadInt32();

            // Now the weapons.
            Int32 weaponCount = reader.ReadInt32();

            for (Int32 x = 0; x < weaponCount; ++x)
            {
                save.Weapons.Add(new Weapon(reader));
            }

            // Some stats?
            save.StatTable.ReadStats(reader);

            // Visited locations.

            Int32 locationsLength = reader.ReadInt32();

            for (Int32 x = 0; x < locationsLength; ++x)
            {
                save.LocationsVisited.Add(LocationExtensions.FromInternalName(reader.BL_ReadString()));
            }

            save.CurrentLocation = LocationExtensions.FromInternalName(reader.BL_ReadString());

            // Some unknown variables.
            // I dunno what this is.
            save.UnknownVariable6  = reader.ReadInt32();
            save.UnknownVariable7  = reader.ReadInt32();
            save.UnknownVariable8  = reader.BL_ReadString();
            save.UnknownVariable9  = reader.ReadInt32();
            save.UnknownVariable10 = reader.ReadInt32();
            save.SaveNumber        = reader.ReadInt32();
            save.UnknownVariable12 = reader.ReadInt32();
            save.UnknownVariable13 = reader.ReadInt32();

            Int32 playthroughCount = reader.ReadInt32();

            for (Int32 x = 0; x < playthroughCount; ++x)
            {
                Playthrough playthrough = new Playthrough();
                save.Playthroughs.Add(playthrough);
                playthrough.Number            = reader.ReadInt32();
                playthrough.ActiveMissionName = reader.BL_ReadString();
                Int32 missionCount = reader.ReadInt32();
                for (Int32 y = 0; y < missionCount; ++y)
                {
                    Mission mission = new Mission {
                        InternalName      = reader.BL_ReadString(),
                        MissionStatusFlag = reader.ReadInt32(),
                        UnknownVariable2  = reader.ReadInt32(),
                        UnknownVariable3  = reader.ReadInt32()
                    };
                    Int32 detailsCount = reader.ReadInt32();
                    for (Int32 z = 0; z < detailsCount; ++z)
                    {
                        Mission.MissionDetails detail = new Mission.MissionDetails();
                        mission.Details.Add(detail);
                        detail.UnknownString   = reader.BL_ReadString();
                        detail.UnknownVariable = reader.ReadInt32();
                    }
                    playthrough.Missions[mission.ID] = mission;
                }
            }

            save.PlayTimeSeconds = reader.ReadInt32();
            save.SaveTimeString  = reader.BL_ReadString();
            save.Name            = reader.BL_ReadString();
            save.Color1ARGB      = reader.ReadUInt32();
            save.Color2ARGB      = reader.ReadUInt32();
            save.Color3ARGB      = reader.ReadUInt32();

            save.UnknownVariable14 = reader.ReadInt32();
            Int32 unknown14Count = reader.ReadInt32();

            for (Int32 x = 0; x < unknown14Count; ++x)
            {
                save.UnknownVariable15.Add(reader.ReadInt32());
            }
            Int32 unknown15Count = reader.ReadInt32();

            for (Int32 x = 0; x < unknown15Count; ++x)
            {
                save.UnknownVariable16.Add(reader.ReadInt32());
            }

            Int32 echoPlaythroughCount = reader.ReadInt32();

            for (Int32 x = 0; x < echoPlaythroughCount; ++x)
            {
                EchoPlaythrough echoPlaythrough = new EchoPlaythrough();
                save.EchoPlaythroughs.Add(echoPlaythrough);
                echoPlaythrough.Playthrough = reader.ReadInt32();
                Int32 echoCount = reader.ReadInt32();
                for (Int32 y = 0; y < echoCount; ++y)
                {
                    Echo echo = new Echo();
                    echoPlaythrough.Echoes.Add(echo);
                    echo.InternalName     = reader.BL_ReadString();
                    echo.UnknownVariable1 = reader.ReadInt32();
                    echo.UnknownVariable2 = reader.ReadInt32();
                }
            }

            //? This seems to be really short, except on my finished save file. Is this banked
            //? data?
            // From the looks of it, maybe? This seems to go right to the end of the file, so
            // there's nothing else to note there.
            // Starts with 0x34, 0x12, 0x21, 0x43. Does it mean anything? It's 1126240820 in dec.
            // Next four bytes are either 9, or 6472 in the save that actually uses it. Hm...
            // Next four are always 0x01, 0xC, 0x00, 0x00. This seems to be 3073 in dec.

            // The first weapon seems to start text 35 bytes in, so maybe it's not all ints. There
            // doesn't seem to be any readable characters though. In particular, at [31], that's
            // the length of the first item string. I'm not too sure where it's indicating

            Int32 unknown17Length = reader.ReadInt32();

            save.UnknownVariable17 = reader.ReadBytes(unknown17Length);

            reader.Close();

            MemoryStream test       = new MemoryStream(save.UnknownVariable17);
            BinaryReader testReader = new BinaryReader(test);
            Int32        u1         = testReader.ReadInt32();
            Int32        u2         = testReader.ReadInt32();
            Int32        u3         = testReader.ReadInt32();
            Int32        u4         = testReader.ReadInt32();
            Int32        u5         = testReader.ReadInt32();
            Int32        u6         = testReader.ReadInt32();
            Int32        u7         = testReader.ReadInt32();
            Int16        u8         = testReader.ReadInt16();
            byte         u9         = testReader.ReadByte();

            if (save.SaveNumber == 10)
            {
                // This is kinda weird. Normally the properties for a weapon or item are stored as
                // a bunch of strings one after the other
                for (int j = 0; j < 8; ++j)
                {
                    string s1  = testReader.BL_ReadString();
                    string s2  = testReader.BL_ReadString();
                    string s3  = testReader.BL_ReadString();
                    int    s4  = testReader.ReadInt32();                 // 0x20?
                    int    s5  = testReader.ReadInt32();                 // 0s?
                    int    s6  = testReader.ReadInt32();                 // 0s?
                    byte   s7  = testReader.ReadByte();                  // 0?
                    string s8  = testReader.BL_ReadString();
                    string s9  = testReader.BL_ReadString();
                    string s10 = testReader.BL_ReadString();
                    int    s11 = testReader.ReadInt32();                  // 0x20?
                    int    s12 = testReader.ReadInt32();                  // 0s?
                    int    s13 = testReader.ReadInt32();                  // 0s?
                    byte   s14 = testReader.ReadByte();                   // 0?
                    if (s9 == "Weapons")
                    {
                        for (int i = 2; i < 14; ++i)
                        {
                            string z1 = testReader.BL_ReadString();
                            string z2 = testReader.BL_ReadString();
                            string z3 = testReader.BL_ReadString();
                            if (i == 2)
                            {
                                int bonusInt = testReader.ReadInt32();
                                Console.WriteLine($"{i}-{j} has a bonus integer {bonusInt}");
                            }
                            int  z4 = testReader.ReadInt32();                            // 0x20?
                            int  z5 = testReader.ReadInt32();                            // 0s?
                            int  z6 = testReader.ReadInt32();                            // 0s?
                            byte z7 = testReader.ReadByte();                             // 0?
                            Console.WriteLine($"Tag {i} weapon {j}: {z1} {z2} {z3} {z4} {z5} {z6} {z7}");
                        }
                        testReader.ReadBytes(15);
                    }
                    else if (s9 == "Gear")
                    {
                        for (int i = 2; i < 9; ++i)
                        {
                            string z1 = testReader.BL_ReadString();
                            string z2 = testReader.BL_ReadString();
                            string z3 = testReader.BL_ReadString();
                            if (i == 8)
                            {
                                int bonusInt1 = testReader.ReadInt32();
                                int bonusInt2 = testReader.ReadInt32();
                                int bonusInt3 = testReader.ReadInt32();
                                Console.WriteLine($"{i}-{j} has bonus integers {bonusInt1} {bonusInt2} {bonusInt3}");
                            }
                            int  z4 = testReader.ReadInt32();                            // 0x20?
                            int  z5 = testReader.ReadInt32();                            // 0s?
                            int  z6 = testReader.ReadInt32();                            // 0s?
                            byte z7 = testReader.ReadByte();                             // 0?
                            Console.WriteLine($"Tag {i} weapon {j}: {z1} {z2} {z3} {z4} {z5} {z6} {z7}");
                            if (i == 2)
                            {
                                int bonusInt = testReader.ReadInt32();
                                Console.WriteLine($"{i}-{j} has a bonus integer {bonusInt}");
                            }
                        }
                    }
                }
            }

            Console.WriteLine($"{save.SaveNumber} is {u1} {u2} {u3} {u4} {u5} {u6} {u7} {u8} {u9}");

            Int32 u10 = testReader.ReadInt32();
            Int32 u11 = testReader.ReadInt32();
            Int32 u12 = testReader.ReadInt32();
            Int32 u13 = testReader.ReadInt32();
            Int32 u14 = testReader.ReadInt32();
            Int32 u15 = testReader.ReadInt32();
            Int32 u16 = testReader.ReadInt32();
            Int32 u17 = testReader.ReadInt32();
            Int32 u18 = testReader.ReadInt32();
            Int32 u19 = testReader.ReadInt32();
            Int32 u20 = testReader.ReadInt32();
            Int32 u21 = testReader.ReadInt32();
            Int32 u22 = testReader.ReadInt32();
            Int32 u23 = testReader.ReadInt32();
            Int32 u24 = testReader.ReadInt32();

            Console.WriteLine($"{save.SaveNumber} is {u10} {u11} {u12} {u13} {u14} {u15} {u16} {u17} {u18} {u19} {u20} {u21} {u22} {u23} {u24}");
            return(save);
        }
Esempio n. 12
0
        public async Task UpdateAsync(Playthrough playthrough)
        {
            context.Update(playthrough);

            await context.SaveChangesAsync();
        }
Esempio n. 13
0
        public async Task CreateAsync(Playthrough playthrough)
        {
            context.Add(playthrough);

            await context.SaveChangesAsync();
        }
Esempio n. 14
0
 //Selects a playthrough from list and highlights it
 public void SelectPlayThrough(int number)
 {
     selectedPlayThrough = allPlaythroughs[number];
     selectedGuid.text   = selectedPlayThrough.id.ToString();
     UpdateTexts();
 }