public void RefreshAllSkinSharedSkinColoredBodyParts()
 {
     foreach (var Customisation in GetComponentsInChildren <BodyPartCustomisationBase>())
     {
         Customisation.Refresh();
     }
 }
Example #2
0
        // This will be a temporal thing until we have proper character traits

        public void OnRaceChange()
        {
            SelectedSpecies++;
            if (SelectedSpecies >= RaceSOSingleton.Instance.Races.Count)
            {
                SelectedSpecies = 0;
            }

            currentCharacter.Species = RaceSOSingleton.Instance.Races[SelectedSpecies].name;

            Cleanup();
            var SetRace = RaceSOSingleton.Instance.Races[SelectedSpecies];

            availableSkinColors = SetRace.Base.SkinColours;
            SetUpSpeciesBody(SetRace);
            PopulateAllDropdowns(SetRace);
            DoInitChecks();

            foreach (var BodyCustomisation in OpenBodyCustomisation)
            {
                BodyCustomisation.Value.Refresh();
            }

            foreach (var Customisation in OpenCustomisation)
            {
                Customisation.Refresh();
            }


            RefreshRace();

            OnSurfaceColourChange();
        }
Example #3
0
 public void SaveExternalCustomisations()
 {
     foreach (var Customisation in OpenCustomisation)
     {
         var newExternalCustomisation = new ExternalCustomisation();
         newExternalCustomisation.Key             = Customisation.thisCustomisations.name;
         newExternalCustomisation.SerialisedValue = Customisation.Serialise();
         ExternalCustomisationStorage.Add(newExternalCustomisation);
     }
 }
Example #4
0
        private void SetAllDropdowns()
        {
            if (currentCharacter.SerialisedBodyPartCustom == null)
            {
                currentCharacter.SerialisedBodyPartCustom = new List <CustomisationStorage>();
            }

            if (currentCharacter.SerialisedExternalCustom == null)
            {
                currentCharacter.SerialisedExternalCustom = new List <ExternalCustomisation>();
            }

            bodyPartCustomisationStorage = new List <CustomisationStorage>(currentCharacter.SerialisedBodyPartCustom);
            ExternalCustomisationStorage = new List <ExternalCustomisation>(currentCharacter.SerialisedExternalCustom);
            if (bodyPartCustomisationStorage == null)
            {
                bodyPartCustomisationStorage = new List <CustomisationStorage>();
            }

            if (ExternalCustomisationStorage == null)
            {
                ExternalCustomisationStorage = new List <ExternalCustomisation>();
            }


            foreach (var Customisation in OpenCustomisation)
            {
                ExternalCustomisation MatchedCustomisation = null;
                foreach (var customisation in ExternalCustomisationStorage)
                {
                    if (customisation.Key == Customisation.thisCustomisations.name)
                    {
                        MatchedCustomisation = customisation;
                    }
                }

                if (MatchedCustomisation != null)
                {
                    Customisation.SetDropdownValue(MatchedCustomisation.SerialisedValue);
                }
            }


            SetDropDownBody(ThisSetRace.Base.Torso);
            SetDropDownBody(ThisSetRace.Base.Head);
            SetDropDownBody(ThisSetRace.Base.ArmLeft);
            SetDropDownBody(ThisSetRace.Base.ArmRight);
            SetDropDownBody(ThisSetRace.Base.LegLeft);
            SetDropDownBody(ThisSetRace.Base.LegRight);
        }
Example #5
0
        public void SetRotation()
        {
            int referenceOffset = 0;

            if (currentDir == CharacterDir.down)
            {
                referenceOffset = 0;
            }

            if (currentDir == CharacterDir.up)
            {
                referenceOffset = 1;
            }

            if (currentDir == CharacterDir.right)
            {
                referenceOffset = 2;
            }

            if (currentDir == CharacterDir.left)
            {
                referenceOffset = 3;
            }

            var Sprites = SpriteContainer.transform.GetComponentsInChildren <SpriteHandlerNorder>();

            var newSprites = Sprites.OrderByDescending(x => x.SpriteOrder.Orders[referenceOffset]).Reverse();

            int i = 0;

            foreach (var Sprite in newSprites)
            {
                Sprite.gameObject.transform.SetSiblingIndex(i);
                i++;
            }

            foreach (var Customisation in OpenCustomisation)
            {
                Customisation.SetRotation(referenceOffset);
            }

            foreach (var PartSprites in OpenBodySprites)
            {
                foreach (var PartSprite in PartSprites.Value)
                {
                    PartSprite.ChangeSpriteVariant(referenceOffset);
                }
            }
        }
Example #6
0
    public SavedData(Customisation custom)
    {
        // Save all player attributes
        skin    = custom.skinIndex;
        hair    = custom.hairIndex;
        mouth   = custom.mouthIndex;
        eyes    = custom.eyesIndex;
        armour  = custom.armourIndex;
        clothes = custom.clothesIndex;

        charName  = custom.charName;                            // Save character name
        health    = custom.stats[0].ToString();                 // Save player health
        mana      = custom.stats[1].ToString();                 // Save player mana
        classType = custom.selectedClass[custom.selectedIndex]; // Save player class
    }
 public void SetGhostMode(bool on)
 {
     if (on)
     {
         Material mat        = Customisation.GetGhostMaterial();
         int      ghostLayer = LayerMask.NameToLayer("Ghost");
         ApplyMaterialLayer(mat, ghostLayer);
     }
     else
     {
         Material mat       = Customisation.GetRealMaterial();
         int      realLayer = LayerMask.NameToLayer("Ignore Raycast");
         ApplyMaterialLayer(mat, realLayer);
     }
 }
Example #8
0
        private object?GetCustomisation(WidgetDescription description)
        {
            if (description.Variant?.Customisation == null)
            {
                return(description.Customisation);
            }

            object customisation = description.Variant.Customisation;

            if (Customisation.IsMergable(description.Customisation))
            {
                Customisation.Merge(customisation, description.Customisation, customisation.GetType());
            }

            return(customisation);
        }
Example #9
0
        public void CreateNewCentreCourse_calls_data_service()
        {
            // Given
            const int    centreId                = 2;
            const int    applicationId           = 1;
            const string customisationName       = "Name";
            const string password                = "******";
            const bool   selfRegister            = false;
            const int    tutCompletionThreshold  = 0;
            const bool   isAssessed              = true;
            const int    diagCompletionThreshold = 0;
            const bool   diagObjSelect           = false;
            const bool   hideInLearnerPortal     = false;
            const string notificationEmails      = "*****@*****.**";

            var customisation = new Customisation(
                centreId,
                applicationId,
                customisationName,
                password,
                selfRegister,
                tutCompletionThreshold,
                isAssessed,
                diagCompletionThreshold,
                diagObjSelect,
                hideInLearnerPortal,
                notificationEmails
                );

            A.CallTo(
                () => courseDataService.CreateNewCentreCourse(customisation)
                ).Returns(123);

            // When
            var result = courseService.CreateNewCentreCourse(customisation);

            // Then
            using (new AssertionScope())
            {
                result.Should().Be(123);
                A.CallTo(
                    () => courseDataService.CreateNewCentreCourse(customisation)
                    ).MustHaveHappenedOnceExactly();
            }
        }
Example #10
0
    public static void SavePlayerCustomisation(Customisation custom)
    {
        // reference to binary formatter (this changing the code into binary language)
        BinaryFormatter formatter = new BinaryFormatter();

        // path to save to "/Save.jpg" file
        string path = Application.persistentDataPath + "/Save.jpg";

        // file stream create file at path
        FileStream stream = new FileStream(path, FileMode.Create);

        // SavedData with player info
        SavedData data = new SavedData(custom);

        // format and serialize location and data
        formatter.Serialize(stream, data);

        // end
        stream.Close();
    }
Example #11
0
        public void OnBodyTypeChange()
        {
            // ThisBodyType
            // AvailableBodyTypes
            SelectedBodyType++;
            if (SelectedBodyType >= AvailableBodyTypes.Count)
            {
                SelectedBodyType = 0;
            }

            SurfaceSprite.Clear();
            var Copy = new Dictionary <BodyPart, List <SpriteHandlerNorder> >(OpenBodySprites);

            foreach (var KVP in Copy)
            {
                foreach (var Sprite in KVP.Value)
                {
                    Destroy(Sprite.gameObject);
                }

                SetupBodyPartsSprites(KVP.Key);
            }

            foreach (var BodyCustomisation in OpenBodyCustomisation)
            {
                BodyCustomisation.Value.Refresh();
            }

            foreach (var Customisation in OpenCustomisation)
            {
                Customisation.Refresh();
            }

            currentCharacter.BodyType = AvailableBodyTypes[SelectedBodyType].bodyType;
            SkinColourChange(CurrentSurfaceColour);
            SetRotation();
            RefreshBodyType();
        }
Example #12
0
        public void CreateNewCentreCourse_correctly_adds_new_course()
        {
            using var transaction = new TransactionScope();
            try
            {
                // Given
                const int    centreId                = 2;
                const int    applicationId           = 1;
                const string customisationName       = "Name";
                const string password                = "******";
                const bool   selfRegister            = false;
                const int    tutCompletionThreshold  = 0;
                const bool   isAssessed              = true;
                const int    diagCompletionThreshold = 0;
                const bool   diagObjSelect           = false;
                const bool   hideInLearnerPortal     = false;
                const string notificationEmails      = "*****@*****.**";
                int?         categoryId              = null;

                var customisation = new Customisation(
                    centreId,
                    applicationId,
                    customisationName,
                    password,
                    selfRegister,
                    tutCompletionThreshold,
                    isAssessed,
                    diagCompletionThreshold,
                    diagObjSelect,
                    hideInLearnerPortal,
                    notificationEmails
                    );

                // When
                var customisationId = courseDataService.CreateNewCentreCourse(customisation);

                var courseDetails = courseDataService.GetCourseDetailsFilteredByCategory(
                    customisationId,
                    centreId,
                    categoryId
                    );

                // Then
                using (new AssertionScope())
                {
                    courseDetails !.CurrentVersion.Should().Be(1);
                    courseDetails.CentreId.Should().Be(centreId);
                    courseDetails.ApplicationId.Should().Be(applicationId);
                    courseDetails.Active.Should().BeTrue();
                    courseDetails.CustomisationName.Should().Be(customisationName);
                    courseDetails.Password.Should().Be(password);
                    courseDetails.SelfRegister.Should().Be(selfRegister);
                    courseDetails.TutCompletionThreshold.Should().Be(tutCompletionThreshold);
                    courseDetails.IsAssessed.Should().Be(isAssessed);
                    courseDetails.DiagCompletionThreshold.Should().Be(diagCompletionThreshold);
                    courseDetails.DiagObjSelect.Should().Be(diagObjSelect);
                    courseDetails.HideInLearnerPortal.Should().Be(hideInLearnerPortal);
                    courseDetails.NotificationEmails.Should().Be(notificationEmails);
                }
            }
            finally
            {
                transaction.Dispose();
            }
        }
 void Awake()
 {
     singleton = this;
 }