Beispiel #1
0
            public static GameObject GetEffectOrb(CreatureBoardAsset creatureBoardAsset)
            {
                GameObject effectOrb   = null;
                GameObject assetLoader = creatureBoardAsset.GetAssetLoader();

                if (assetLoader != null)
                {
                    effectOrb = assetLoader.FindChild(STR_EffectOrb, true);
                }
                return(effectOrb);
            }
Beispiel #2
0
            public static GameObject AttachEffect(CreatureBoardAsset creatureBoardAsset, string effectName, string spellId, float enlargeTime, float lifeTime, float shrinkTime, string parentNodeName = null, string prefix = null)
            {
                GameObject spell = GetEffect(effectName);

                if (spell == null)
                {
                    Log.Error($"Spell effect \"{effectName}\" not found. Unable to Attach the effect.");
                    return(null);
                }

                //Log.Indent("Spells.AttachEffect");

                spell.name = GetAttachedEffectName(spellId, prefix);

                GameObject creatureBase    = creatureBoardAsset.GetAssetLoader();
                Transform  parentTransform = creatureBase.transform;

                if (parentNodeName != null)
                {
                    GameObject parentNode = creatureBase.FindChild(parentNodeName, true);
                    if (parentNode != null)
                    {
                        parentTransform = parentNode.transform;
                    }
                }

                // TODO: IS the same technique required for localScale?
                Vector3 savePosition = spell.transform.localPosition;

                spell.transform.SetParent(parentTransform);
                spell.transform.position      = parentTransform.position;
                spell.transform.localPosition = savePosition;

                if (parentNodeName != null)
                {
                    spell.transform.localEulerAngles = Vector3.zero;
                }

                EffectParameters.ApplyAfterPositioning(spell);

                if (lifeTime > 0)
                {
                    Instances.AddTemporal(spell, lifeTime, 2f * shrinkTime / 3f, enlargeTime, shrinkTime);
                }
                else if (enlargeTime > 0)
                {
                    Instances.EnlargeSoon(spell, enlargeTime);
                }

                //Log.Unindent("Spells.AttachEffect");
                return(spell);
            }
Beispiel #3
0
            private static void InitializeNewlyCreatedPersistentEffect(CreatureBoardAsset creatureAsset, IOldPersistentEffect persistentEffect, string newCreatureName)
            {
                Log.Indent();
                GameObject assetLoader = creatureAsset.GetAssetLoader();

                if (assetLoader != null)
                {
                    GameObject effectOrb    = InitializeOrb(assetLoader);
                    GameObject attachedNode = AddAttachmentNode(assetLoader);

                    AttachEffect(creatureAsset, persistentEffect, newCreatureName);

                    persistentEffectEventArgs.Set(creatureAsset, assetLoader, effectOrb, attachedNode, persistentEffect);
                    OnPersistentEffectInitialized(creatureAsset, persistentEffectEventArgs);
                }
                Log.Unindent();
            }
Beispiel #4
0
            private static bool IsMiniAnUninitializedEffect(CreatureBoardAsset creatureAsset)
            {
                if (!creatureAsset.HasAttachedData(STR_PersistentEffect))
                {
                    return(false);
                }

                GameObject assetLoader = creatureAsset.GetAssetLoader();

                if (assetLoader == null)
                {
                    return(false);
                }

                GameObject goatClone = assetLoader.FindChild(STR_UninitializedMiniMeshName);

                return(goatClone != null);
            }
Beispiel #5
0
            // TODO: Refactor this. Hard to read.
            internal static bool InitializeMiniFromPersistentEffect(CreatureBoardAsset creatureAsset, IOldPersistentEffect persistentEffect, string newCreatureName)
            {
                //Log.Indent();
                try
                {
                    GameObject assetLoader = creatureAsset.GetAssetLoader();
                    //Log.Warning($"creatureAsset.Creature.Name = \"{creatureAsset.Creature.Name}\"");
                    if (assetLoader != null)
                    {
                        GameObject goatClone = assetLoader.FindChild(STR_UninitializedMiniMeshName);
                        if (goatClone != null)
                        {
                            MeshFilter   meshFilter   = goatClone.GetComponent <MeshFilter>();
                            MeshRenderer meshRenderer = goatClone.GetComponent <MeshRenderer>();
                            if (meshFilter != null && meshRenderer != null)
                            {
                                PositionOrb(goatClone);

                                ReplaceMaterial(meshFilter, meshRenderer);

                                if (persistentEffect == null)
                                {
                                    persistentEffect = creatureAsset.GetPersistentEffect();
                                    if (persistentEffect == null)
                                    {
                                        Log.Error($"persistentEffect is null! Creating Waterfall!");
                                        persistentEffect = new OldPersistentEffect()
                                        {
                                            EffectName = "R1.WaterWallSegment1"
                                        };
                                    }
                                }

                                InitializeNewlyCreatedPersistentEffect(creatureAsset, persistentEffect, newCreatureName);

                                updatedCreatures.Add(creatureAsset.CreatureId.ToString());

                                Log.Debug($"returning true");
                                return(true);
                            }
                            else
                            {
                                Log.Debug($"Mesh Filter or Mesh Renderer not found in this update cycle...");
                            }
                        }
                        else
                        {
                            if (assetLoader.FindChild(STR_EffectOrb) != null)
                            {
                                //if (effectsToInitialize.Count > 0)
                                //	Log.Warning($"effectsToInitialize.Count = {effectsToInitialize.Count}");
                                //if (updatedCreatures.Count > 0)
                                //	Log.Warning($"updatedCreatures.Count = {updatedCreatures.Count}");

                                //Log.Warning($"Already initialized. Adding {creatureAsset.CreatureId.ToString()} to updatedCreatures");

                                persistentEffect = creatureAsset.GetPersistentEffect();
                                GameObject effectOrb    = GetEffectOrb(creatureAsset);
                                GameObject attachedNode = creatureAsset.GetAttachedParentGameObject();
                                if (attachedNode != null)
                                {
                                    persistentEffectEventArgs.Set(creatureAsset, assetLoader, effectOrb, attachedNode, persistentEffect);
                                    OnPersistentEffectInitialized(creatureAsset, persistentEffectEventArgs);
                                }
                                else
                                {
                                    Log.Error($"attachedNode is null!!!");
                                }

                                updatedCreatures.Add(creatureAsset.CreatureId.ToString());
                            }
                            else
                            {
                                Log.Debug($"goatClone not found in this update cycle...");
                            }
                        }
                    }
                    else
                    {
                        Log.Debug($"Asset Loader not found in this update cycle...");
                    }
                    //Log.Debug($"returning false");
                    return(false);
                }
                finally
                {
                    //Log.Unindent();
                }
            }