public static GameObject CreateDefaultTextObject()
        {
            var textPrefab = PrefabAPI.InstantiateClone(Resources.Load <GameObject>("prefabs/effects/DamageRejected"), "DeathMessageAboveCorpse_DefaultTextObjectChild");

            textPrefab.name = "DeathMessageAboveCorpse_DefaultTextObject";
            UnityEngine.Object.Destroy(textPrefab.GetComponent <EffectComponent>());
            textPrefab.GetComponent <ObjectScaleCurve>().overallCurve = AnimationCurve.Constant(0f, 1f, 1f);
            UnityEngine.Object.Destroy(textPrefab.GetComponent <VelocityRandomOnStart>());
            UnityEngine.Object.Destroy(textPrefab.GetComponent <ConstantForce>());
            UnityEngine.Object.Destroy(textPrefab.GetComponent <Rigidbody>());
            UnityEngine.Object.Destroy(textPrefab.transform.Find("TextMeshPro").gameObject.GetComponent <ScaleSpriteByCamDistance>());
            textPrefab.AddComponent <NetworkIdentity>();

            DeathMessageLocator deathMessageLocator = textPrefab.AddComponent <DeathMessageLocator>();

            deathMessageLocator.textMeshPro                     = textPrefab.transform.Find("TextMeshPro").gameObject.GetComponent <TextMeshPro>();
            deathMessageLocator.textMeshPro.fontSize            = fontSize;
            deathMessageLocator.languageTextMeshController      = textPrefab.transform.Find("TextMeshPro").gameObject.GetComponent <LanguageTextMeshController>();
            deathMessageLocator.destroyOnTimer                  = textPrefab.GetComponent <DestroyOnTimer>();
            textPrefab.GetComponent <DestroyOnTimer>().duration = cfgDuration.Value > 0 ? cfgDuration.Value : 360000;

            PrefabAPI.RegisterNetworkPrefab(textPrefab);
            defaultTextObject = textPrefab;
            return(textPrefab);
        }
Esempio n. 2
0
            public void OnReceived()
            {
                if (NetworkServer.active && !NetworkClient.active)
                {
                    if (debugging)
                    {
                        Chat.SendBroadcastChat(new Chat.SimpleChatMessage
                        {
                            baseToken = "Client: Server ran code."
                        });
                    }
                    return;
                }

                if (debugging)
                {
                    Chat.SendBroadcastChat(new Chat.SimpleChatMessage
                    {
                        baseToken = "Client: Received."
                    });
                }

                var typingText = UnityEngine.Object.Instantiate(defaultTextObject);

                typingText.transform.position = position;
                DeathMessageLocator deathMessageLocator = typingText.GetComponent <DeathMessageLocator>();

                deathMessageLocator.quoteIndex = index;
            }
            private void PerformSingleplayerAction(Vector3 position)
            {
                var quoteIndex = UnityEngine.Random.Range(0, deathMessagesResolved.Length);
                var typingText = UnityEngine.Object.Instantiate(defaultTextObject);

                typingText.transform.position = position;
                DeathMessageLocator deathMessageLocator = typingText.GetComponent <DeathMessageLocator>();

                deathMessageLocator.quoteIndex = quoteIndex;
            }