Example #1
0
        /// <summary>
        /// Initializes character renderers with selected sprites.
        /// </summary>
        private void TryInitialize()
        {
            if (Expressions.All(i => i.Name != "Default") || Expressions.All(i => i.Name != "Angry") || Expressions.All(i => i.Name != "Dead"))
            {
                throw new Exception("Character must have at least 3 basic expressions: Default, Angry and Dead.");
            }

            HeadRenderer.sprite          = Head;
            HairRenderer.sprite          = Hair;
            HairRenderer.maskInteraction = Helmet == null || Helmet.name.Contains("[FullHair]") ? SpriteMaskInteraction.None : SpriteMaskInteraction.VisibleInsideMask;
            EarsRenderer.sprite          = Ears;
            SetExpression(Expression);
            BeardRenderer.sprite = Beard;
            EarsRenderer.sprite  = Ears;
            MapSprites(BodyRenderers, Body);
            HelmetRenderer.sprite   = Helmet;
            GlassesRenderer.sprite  = Glasses;
            MaskRenderer.sprite     = Mask;
            EarringsRenderer.sprite = Earrings;
            MapSprites(ArmorRenderers, Armor);
            CapeRenderer.sprite = Cape;
            BackRenderer.sprite = Back;
            PrimaryMeleeWeaponRenderer.sprite       = PrimaryMeleeWeapon;
            SecondaryMeleeWeaponRenderer.sprite     = SecondaryMeleeWeapon;
            BowRenderers.ForEach(i => i.sprite      = Bow.SingleOrDefault(j => j != null && i.name.Contains(j.name)));
            FirearmsRenderers.ForEach(i => i.sprite = Firearms.SingleOrDefault(j => j != null && i.name.Contains(j.name)));
            ShieldRenderer.sprite = Shield;

            PrimaryMeleeWeaponRenderer.enabled   = WeaponType != WeaponType.Bow;
            SecondaryMeleeWeaponRenderer.enabled = WeaponType == WeaponType.MeleePaired;
            BowRenderers.ForEach(i => i.enabled  = WeaponType == WeaponType.Bow);

            if (Hair != null && Hair.name.Contains("[HideEars]") && HairRenderer.maskInteraction == SpriteMaskInteraction.None)
            {
                EarsRenderer.sprite = null;
            }

            switch (WeaponType)
            {
            case WeaponType.Firearms1H:
            case WeaponType.Firearms2H:
                Firearm.AmmoShooted = 0;
                BuildFirearms(Firearm.Params);
                break;
            }
        }
        /// <summary>
        /// Initializes character renderers with selected sprites.
        /// </summary>
        private void TryInitialize()
        {
            HeadRenderer.sprite          = Head;
            HairRenderer.sprite          = Hair;
            HairRenderer.maskInteraction = HelmetMask == null ? SpriteMaskInteraction.None : SpriteMaskInteraction.VisibleOutsideMask;
            HairMask.sprite             = HelmetMask;
            EarsRenderer.sprite         = Ears;
            EyebrowsRenderers[0].sprite = Eyebrows;
            EyesRenderers[0].sprite     = Eyes;
            MouthRenderers[0].sprite    = Mouth;
            BeardRenderer.sprite        = Beard;
            EarsRenderer.sprite         = Ears;
            MapSprites(BodyRenderers, Body);
            HelmetRenderer.sprite   = Helmet;
            GlassesRenderer.sprite  = Glasses;
            MaskRenderer.sprite     = Mask;
            EarringsRenderer.sprite = Earrings;
            MapSprites(ArmorRenderers, Armor);
            CapeRenderer.sprite = Cape;
            BackRenderer.sprite = Back;
            PrimaryMeleeWeaponRenderer.sprite       = PrimaryMeleeWeapon;
            SecondaryMeleeWeaponRenderer.sprite     = SecondaryMeleeWeapon;
            BowRenderers.ForEach(i => i.sprite      = Bow.SingleOrDefault(j => j != null && i.name.Contains(j.name)));
            FirearmsRenderers.ForEach(i => i.sprite = Firearms.SingleOrDefault(j => j != null && i.name.Contains(j.name)));
            ShieldRenderer.sprite = Shield;

            PrimaryMeleeWeaponRenderer.enabled   = WeaponType != WeaponType.Bow;
            SecondaryMeleeWeaponRenderer.enabled = WeaponType == WeaponType.MeleePaired;
            BowRenderers.ForEach(i => i.enabled  = WeaponType == WeaponType.Bow);

            switch (HairMaskType)
            {
            case HairMaskType.None:
                HairRenderer.maskInteraction = SpriteMaskInteraction.None;
                HairMask.sprite = null;
                break;

            case HairMaskType.HelmetMask:
                HairRenderer.maskInteraction = HelmetMask == null ? SpriteMaskInteraction.None : SpriteMaskInteraction.VisibleOutsideMask;
                HairMask.sprite = HelmetMask;
                break;

            case HairMaskType.HeadMask:
                HairRenderer.maskInteraction = Head == null ? SpriteMaskInteraction.None : SpriteMaskInteraction.VisibleInsideMask;
                HairMask.sprite = HeadMask;
                break;
            }

            if (Hair != null && Hair.name.Contains("[HideEars]"))
            {
                EarsRenderer.sprite = null;
            }

            if (Hair != null && Hair.name.Contains("[HideHelm]"))
            {
                HairRenderer.maskInteraction = SpriteMaskInteraction.None;
                HelmetRenderer.sprite        = null;
            }

            switch (WeaponType)
            {
            case WeaponType.Firearms1H:
            case WeaponType.Firearms2H:
                Firearm.AmmoShooted = 0;
                BuildFirearms(Firearm.Params);
                break;
            }
        }