Exemple #1
0
        private static void CreateOverheadCard(FoyerCharacterSelectFlag selectCharacter, CustomCharacterData data)
        {
            //Create new card instance
            selectCharacter.ClearOverheadElement();
            selectCharacter.OverheadElement = FakePrefab.Clone(selectCharacter.OverheadElement);
            selectCharacter.OverheadElement.SetActive(true);

            string replaceKey = data.baseCharacter.ToString().ToUpper();

            if (data.baseCharacter == PlayableCharacters.Soldier)
            {
                replaceKey = "MARINE";
            }
            if (data.baseCharacter == PlayableCharacters.Pilot)
            {
                replaceKey = "ROGUE";
            }
            if (data.baseCharacter == PlayableCharacters.Eevee)
            {
                replaceKey = "PARADOX";
            }

            //Change text
            var infoPanel = selectCharacter.OverheadElement.GetComponent <FoyerInfoPanelController>();

            dfLabel nameLabel = infoPanel.textPanel.transform.Find("NameLabel").GetComponent <dfLabel>();

            nameLabel.Text = nameLabel.GetLocalizationKey().Replace(replaceKey, data.nameShort.ToUpper());

            dfLabel pastKilledLabel = infoPanel.textPanel.transform.Find("PastKilledLabel").GetComponent <dfLabel>();

            pastKilledLabel.Text = "(No Past)";

            infoPanel.itemsPanel.enabled = false;

            /*
             * infoPanel.itemsPanel.ResolutionChangedPostLayout += (a, b, c) =>
             * {
             *  infoPanel.itemsPanel.IsVisible = false;
             *  Tools.Print("called");
             * };
             */

            //Swap out face sprites
            if (data.foyerCardSprites != null)
            {
                var facecard       = selectCharacter.OverheadElement.GetComponentInChildren <CharacterSelectFacecardIdleDoer>();
                var orig           = facecard.sprite.Collection;
                var copyCollection = GameObject.Instantiate(orig);

                tk2dSpriteDefinition[] copyDefinitions = new tk2dSpriteDefinition[orig.spriteDefinitions.Length];
                for (int i = 0; i < copyCollection.spriteDefinitions.Length; i++)
                {
                    copyDefinitions[i] = orig.spriteDefinitions[i].Copy();
                }
                copyCollection.spriteDefinitions = copyDefinitions;

                for (int i = 0; i < data.foyerCardSprites.Count; i++)
                {
                    var tex = data.foyerCardSprites[i];
                    var def = copyCollection.GetSpriteDefinition(tex.name);

                    if (def != null)
                    {
                        def.ReplaceTexture(tex);
                        Console.WriteLine($"REPLACED {def.name} {def.material.mainTexture.width} {def.material.mainTexture.height}");
                    }
                }
                facecard.sprite.Collection = copyCollection;

                facecard.spriteAnimator.Library = GameObject.Instantiate(facecard.spriteAnimator.Library);
                GameObject.DontDestroyOnLoad(facecard.spriteAnimator.Library);
                foreach (var clip in facecard.spriteAnimator.Library.clips)
                {
                    for (int i = 0; i < clip.frames.Length; i++)
                    {
                        clip.frames[i].spriteCollection = copyCollection;
                    }
                }

                Console.WriteLine($"FOYERCARDDBG");
                for (int i = 0; i < copyCollection.spriteDefinitions.Length; i++)
                {
                    var def = copyCollection.spriteDefinitions[i];
                    Console.WriteLine(def.name);
                    if (!def.name.Contains("facecard"))
                    {
                        continue;
                    }

                    Console.WriteLine("FACECARD");
                    Console.WriteLine($"{def.material.mainTexture.width} {def.material.mainTexture.height} {def.uvs[0].x},{def.uvs[0].y} {def.uvs[1].x},{def.uvs[1].y} {def.uvs[2].x},{def.uvs[2].y} {def.uvs[3].x},{def.uvs[3].y} ");
                }
            }
            selectCharacter.OverheadElement.SetActive(false);
        }
Exemple #2
0
        public static void BuildCharacter(CustomCharacterData data, bool hasAltSkin, bool paradoxUsesSprites, bool removeFoyerExtras, bool hasArmourlessAnimations = false, bool usesArmourNotHealth = false, bool hasCustomPast = false, string customPast = "", int metaCost = 0, bool useGlow = false,
                                          GlowMatDoer glowVars = null, GlowMatDoer altGlowVars = null)
        {
            var basePrefab = GetPlayerPrefab(data.baseCharacter);

            if (basePrefab == null)
            {
                ToolsCharApi.PrintError("Could not find prefab for: " + data.baseCharacter.ToString());
                return;
            }

            ToolsCharApi.Print("");
            ToolsCharApi.Print("--Building Character: " + data.nameShort + "--", "0000FF");

            PlayerController playerController;
            GameObject       gameObject = GameObject.Instantiate(basePrefab);

            playerController = gameObject.GetComponent <PlayerController>();
            var customCharacter = gameObject.AddComponent <CustomCharacter>();

            customCharacter.data = data;
            data.characterID     = storedCharacters.Count;

            playerController.AllowZeroHealthState = usesArmourNotHealth;
            playerController.ForceZeroHealthState = usesArmourNotHealth;

            playerController.hasArmorlessAnimations = hasArmourlessAnimations;


            playerController.altHandName           = "hand_alt";
            playerController.SwapHandsOnAltCostume = true;


            GameObject.DontDestroyOnLoad(gameObject);

            CustomizeCharacter(playerController, data, paradoxUsesSprites);

            data.useGlow = useGlow;

            if (useGlow)
            {
                data.emissiveColor      = glowVars.emissiveColor;
                data.emissiveColorPower = glowVars.emissiveColorPower;
                data.emissivePower      = glowVars.emissivePower;
            }
            data.removeFoyerExtras = removeFoyerExtras;
            data.metaCost          = metaCost;

            if (useGlow)
            {
                var material = new Material(EnemyDatabase.GetOrLoadByName("GunNut").sprite.renderer.material);
                //var material = new Material(ShaderCache.Acquire("Brave/UnlitTintableCutoutEmissive"));
                material.DisableKeyword("BRIGHTNESS_CLAMP_ON");
                material.EnableKeyword("BRIGHTNESS_CLAMP_OFF");
                material.SetTexture("_MainTexture", material.GetTexture("_MainTex"));
                material.SetColor("_EmissiveColor", glowVars.emissiveColor);
                material.SetFloat("_EmissiveColorPower", glowVars.emissiveColorPower);
                material.SetFloat("_EmissivePower", glowVars.emissivePower);
                material.SetFloat("_EmissiveThresholdSensitivity", 0.5f);

                data.glowMaterial = material;
            }

            if (useGlow && hasAltSkin)
            {
                var material = new Material(EnemyDatabase.GetOrLoadByName("GunNut").sprite.renderer.material);
                //var material = new Material(ShaderCache.Acquire("Brave/UnlitTintableCutoutEmissive"));
                material.DisableKeyword("BRIGHTNESS_CLAMP_ON");
                material.EnableKeyword("BRIGHTNESS_CLAMP_OFF");
                material.SetTexture("_MainTexture", material.GetTexture("_MainTex"));
                material.SetColor("_EmissiveColor", altGlowVars.emissiveColor);
                material.SetFloat("_EmissiveColorPower", altGlowVars.emissiveColorPower);
                material.SetFloat("_EmissivePower", altGlowVars.emissivePower);
                material.SetFloat("_EmissiveThresholdSensitivity", 0.5f);

                data.altGlowMaterial = material;
            }

            data.normalMaterial = new Material(ShaderCache.Acquire("Brave/PlayerShader"));



            basePrefab = null;
            storedCharacters.Add(data.nameInternal.ToLower(), new Tuple <CustomCharacterData, GameObject>(data, gameObject));
            //BotsModule.Log("nameInternal: " + data.nameInternal, BotsModule.TEXT_COLOR);

            customCharacter.past    = customPast;
            customCharacter.hasPast = hasCustomPast;



            gameObject.SetActive(false);
            FakePrefab.MarkAsFakePrefab(gameObject);
        }