예제 #1
0
            public static void ClearAttached(string spellId, string creatureId)
            {
                CreatureBoardAsset creatureBoardAsset = Minis.GetCreatureBoardAsset(creatureId);

                if (creatureBoardAsset == null)
                {
                    Log.Error($"CreatureBoardAsset matching id {creatureId} not found!");
                    return;
                }

                GameObject creatureBase       = creatureBoardAsset.GetBase();
                string     attachedEffectName = GetAttachedEffectName(spellId);

                GameObject childEffect = creatureBase.FindChild(attachedEffectName);

                if (childEffect == null)
                {
                    Log.Error($"Child effect {attachedEffectName} not found.");
                    return;
                }

                while (childEffect != null)
                {
                    childEffect.transform.SetParent(null);
                    Instances.AddTemporal(childEffect, 2, 2);
                    childEffect = creatureBase.FindChild(attachedEffectName);
                }
            }
예제 #2
0
            private static float GetDistanceInFeet(Vector3 position, CreatureBoardAsset creatureBoardAsset)
            {
                GameObject gameObject = creatureBoardAsset.GetBase();

                if (gameObject == null)
                {
                    return(float.MaxValue);
                }

                float distanceTiles = (gameObject.transform.position - position).magnitude;

                return(Convert.TilesToFeet(distanceTiles));
            }
예제 #3
0
            private static void PlayEffect(string effectName, string spellId, string creatureId, float lifeTime, float enlargeTimeSeconds, float secondsDelayStart, float shrinkTime, SpellLocation location, float rotationDegrees, bool isMoveable)
            {
                if (secondsDelayStart > 0)
                {
                    Log.Debug($"QueueEffect \"{effectName}\" for {secondsDelayStart} seconds...");
                    QueueEffect(new WaitingToCast(location, secondsDelayStart, effectName, spellId, creatureId, enlargeTimeSeconds, lifeTime, null, shrinkTime, rotationDegrees, isMoveable));
                    return;
                }

                CreatureBoardAsset creatureBoardAsset = Minis.GetCreatureBoardAsset(creatureId);

                if (creatureBoardAsset == null)
                {
                    Log.Error($"CreatureBoardAsset matching id {creatureId} not found!");
                    return;
                }

                GameObject spell = GetSpell(effectName, spellId, lifeTime, enlargeTimeSeconds, shrinkTime, rotationDegrees, isMoveable);

                if (spell == null)
                {
                    Log.Error($"Spell name \"{effectName}\" not found!");
                    return;
                }

                GameObject creatureBase = creatureBoardAsset.GetBase();

                if (location == SpellLocation.CreatureCastSpell)
                {
                    Log.Vector("creatureBoardAsset.HookSpellCast.position", creatureBoardAsset.HookSpellCast.position);
                    spell.transform.position = creatureBoardAsset.HookSpellCast.position;
                }
                else                  // Default to base position...
                {
                    spell.transform.position = creatureBase.transform.position;
                }

                float creatureRotationDegrees = creatureBoardAsset.GetRotationDegrees();

                spell.transform.Rotate(Vector3.up, creatureRotationDegrees);
                //spell.transform.localEulerAngles = new Vector3(spell.transform.localEulerAngles.x, rotationDegrees, spell.transform.localEulerAngles.z);
                //Log.Vector("spell.transform.localEulerAngles", spell.transform.localEulerAngles);
                //spell.transform.Rotate(creatureBoardAsset.GetRotation());
                //Log.Vector("spell.transform.localEulerAngles2", spell.transform.localEulerAngles);

                if (isMoveable)
                {
                    Log.Warning($"EffectParameters.ApplyAfterPositioning(spell) on moveable effect {effectName}");
                }
                EffectParameters.ApplyAfterPositioning(spell, isMoveable);
            }
예제 #4
0
            private static void RemoveTargetFrom(CreatureBoardAsset creatureBoardAsset)
            {
                if (creatureBoardAsset == null)
                {
                    return;
                }
                GameObject baseGameObject = creatureBoardAsset.GetBase();
                GameObject targetDisk     = baseGameObject.transform.GetChild(STR_TargetDisk);

                if (targetDisk != null)
                {
                    targetDisks.Remove(targetDisk);
                    UnityEngine.Object.Destroy(targetDisk);
                }
            }
예제 #5
0
            public static void RestoreCamera(bool doLook = false)
            {
                if (saveParent != null)
                {
                    Vector3 position = saveCameraTransform.position;

                    saveCameraTransform.SetParent(saveParent);

                    //if (saveCameraTransform.localEulerAngles == saveEulerAngles)
                    //	Log.Warning($"saveCamera.gameObject.transform.eulerAngles == saveEulerAngles");

                    saveCameraTransform.position = position;

                    if (targetWorldIdForRestoreCamera != null)
                    {
                        CreatureBoardAsset creatureBoardAsset = Minis.GetCreatureBoardAsset(targetWorldIdForRestoreCamera);
                        if (creatureBoardAsset != null)
                        {
                            GameObject baseGO = creatureBoardAsset.GetBase();
                            if (baseGO != null && doLook)
                            {
                                CameraController.LookAtTarget(baseGO.transform.position);
                            }
                        }
                    }

                    saveCameraTransform.localEulerAngles = saveEulerAngles;

                    saveParent          = null;
                    saveCameraTransform = null;
                    UnityEngine.Object.Destroy(spinner);
                    spinner = null;
                }
                else
                {
                    GameObject cameraRoot = GetRoot();
                    if (cameraRoot != null)
                    {
                        GameObject mainCamera = cameraRoot.FindChild("MainCamera");
                        if (mainCamera != null)
                        {
                            mainCamera.transform.localEulerAngles = Vector3.zero;
                        }
                    }
                }
            }
예제 #6
0
            static bool IsTargeted(CreatureBoardAsset creatureBoardAsset)
            {
                GameObject baseGameObject = creatureBoardAsset.GetBase();

                if (baseGameObject == null)
                {
                    return(false);
                }
                Transform baseTransform = baseGameObject.transform;

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

                return(baseTransform.HasChild(STR_TargetDisk));
            }
예제 #7
0
            private static void AddTargetTo(CreatureBoardAsset creatureBoardAsset)
            {
                if (creatureBoardAsset == null)
                {
                    return;
                }
                GameObject baseGameObject = creatureBoardAsset.GetBase();
                Transform  baseTransform  = baseGameObject.transform;

                if (baseTransform.HasChild(STR_TargetDisk))
                {
                    Log.Warning($"{creatureBoardAsset.name}'s base transform already has a child STR_TargetDisk!");
                    return;
                }

                Minis.Surprise(creatureBoardAsset);

                Vector3 basePosition = baseTransform.position;

                // Bump the target position up a bit...
                Vector3 targetPosition = new Vector3(basePosition.x, basePosition.y + 0.05f, basePosition.z);

                AddTarget(targetPosition, baseTransform, creatureBoardAsset.CreatureScale, WhatSide(creatureBoardAsset.Creature.CreatureId.Value));
            }
예제 #8
0
            public static CreatureBoardAsset SetActiveTurn(string creatureId, string color)
            {
                Log.Debug($"SetActiveTurn...");

                ClearActiveTurnIndicator();

                CreatureBoardAsset creatureAsset = GetCreatureBoardAsset(creatureId);

                if (creatureAsset == null)
                {
                    Log.Error($"SetActiveTurn - creatureId {creatureId} not found.");
                    return(null);
                }

                GameObject baseGameObject = creatureAsset.GetBase();

                if (baseGameObject == null)
                {
                    Log.Error($"SetActiveTurn - baseGameObject for {creatureId} not found.");
                    return(null);
                }

                string effectName;

                if (creatureAsset.CreatureScale == 2)
                {
                    effectName = "ActiveTurn2x2";
                }
                else if (creatureAsset.CreatureScale == 3)
                {
                    effectName = "ActiveTurn3x3";
                }
                else if (creatureAsset.CreatureScale == 4)
                {
                    effectName = "ActiveTurn4x4";
                }
                else if (creatureAsset.CreatureScale == 0.5)
                {
                    effectName = "ActiveTurn0.5x0.5";
                }
                else
                {
                    effectName = "ActiveTurn1x1";
                }

                Log.Debug($"activeTurnIndicator = Prefabs.Clone(\"{effectName}\");");
                activeTurnIndicator = Prefabs.Clone(effectName);

                if (activeTurnIndicator == null)
                {
                    Log.Error($"SetActiveTurn - Prefabs.Clone(\"{effectName}\") returned null.");
                    return(null);
                }

                SetTurnIndicatorColor(activeTurnIndicator, color, creatureAsset.CreatureScale);

                Log.Debug($"activeTurnIndicator.transform.SetParent(baseGameObject.transform);");
                activeTurnIndicator.transform.SetParent(baseGameObject.transform);
                activeTurnIndicator.transform.position = creatureAsset.transform.position;
                return(creatureAsset);
            }