Пример #1
0
 private static void BoardToolManager_OnSwitchTool(BoardTool obj)
 {
     if (obj is CreatureMoveBoardTool)
     {
         CreatureBoardAsset selectedCreature = Minis.GetSelected();
         draggingPersistentEffect = selectedCreature.GetPersistentEffect();
         if (draggingPersistentEffect != null && draggingPersistentEffect.RotationIsLocked)
         {
             trackingDraggedMiniForRotationLock = true;
         }
     }
     else
     {
         if (draggingPersistentEffect != null && trackingDraggedMiniForRotationLock)
         {
             CreatureBoardAsset selectedCreature = Minis.GetSelected();
             if (selectedCreature != null)
             {
                 selectedCreature.SetRotationDegrees(draggingPersistentEffect.LockedRotation);
             }
         }
         draggingPersistentEffect           = null;
         trackingDraggedMiniForRotationLock = false;
     }
 }
Пример #2
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);
                }
            }
Пример #3
0
            static void BoardHasBecomeActive(bool logMinis = false)
            {
                if (logMinis)
                {
                    Log.Warning($"BoardHasBecomeActive - minis we see now:");
                }

                CreatureBoardAsset[] allMinis = Minis.GetAll();
                foreach (CreatureBoardAsset creatureBoardAsset in allMinis)
                {
                    Creature creature = creatureBoardAsset.GetComponent <Creature>();
                    if (logMinis)
                    {
                        if (creature != null)
                        {
                            Log.Debug($"  {creature.Name} ({creatureBoardAsset.Creature.CreatureId.Value})");
                        }
                        else
                        {
                            Log.Warning($"  <Creature> component missing! ({creatureBoardAsset.Creature.CreatureId.Value})");
                        }
                    }
                }
                if (logMinis)
                {
                    Log.Debug($"-----------------------");
                    Log.Debug($"");
                }
                boardActivationTime = Time.time;
            }
Пример #4
0
            public static bool IsPersistentEffect(string creatureId)
            {
                CreatureBoardAsset creatureBoardAsset = Minis.GetCreatureBoardAsset(creatureId);

                if (creatureBoardAsset != null)
                {
                    return(creatureBoardAsset.IsPersistentEffect());
                }
                return(false);
            }
Пример #5
0
            /// <summary>
            /// Drops a target on the base of the specified creature.
            /// </summary>
            /// <param name="creatureId"></param>
            public static void Drop(string creatureId)
            {
                Log.Debug($"Target.Drop {creatureId}!");
                CreatureBoardAsset creatureBoardAsset = Minis.GetCreatureBoardAsset(creatureId);

                if (creatureBoardAsset != null)
                {
                    Log.Debug($"creature found!");
                    AddTargetTo(creatureBoardAsset);
                }
            }
Пример #6
0
            static CreatureBoardAsset RemoveTargetFromNearestCreature()
            {
                CreatureBoardAsset creatureBoardAsset = Minis.GetCreatureClosestTo(Flashlight.GetPosition(), maxDistanceToNearestCreatureFt);

                if (creatureBoardAsset == null)
                {
                    return(null);
                }
                RemoveTargetFrom(creatureBoardAsset);

                return(creatureBoardAsset);
            }
Пример #7
0
            public static CreatureBoardAsset LookAt(string id)
            {
                CreatureBoardAsset creatureBoardAsset = Minis.GetCreatureBoardAsset(id);

                if (creatureBoardAsset != null)
                {
                    CreatureGuid creatureGuid = new CreatureGuid(creatureBoardAsset.Creature.CreatureId.Value);
                    CameraController.LookAtCreature(creatureGuid);
                }

                return(creatureBoardAsset);
            }
Пример #8
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);
            }
Пример #9
0
            static void StorePersistentData(CreatureGuid iD, IOldPersistentEffect persistentEffect)
            {
                Log.Indent();
                CreatureBoardAsset creatureBoardAsset = Minis.GetCreatureBoardAsset(iD.ToString());

                if (creatureBoardAsset != null)
                {
                    SavePersistentEffect(creatureBoardAsset, persistentEffect);
                }
                else
                {
                    Log.Error($"StorePersistentData -- creatureBoardAsset is null!");
                }

                Log.Unindent();
            }
Пример #10
0
 static void CheckForNewMinis()
 {
     CreatureBoardAsset[] allMinis = Minis.GetAll();
     if (lastMiniCount == allMinis.Length)
     {
         return;
     }
     lastMiniCount = allMinis.Length;
     foreach (CreatureBoardAsset creatureBoardAsset in allMinis)
     {
         if (IsMiniAnUninitializedEffect(creatureBoardAsset))
         {
             InitializeMiniAsEffect(creatureBoardAsset);
         }
     }
 }
Пример #11
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;
                        }
                    }
                }
            }
Пример #12
0
            public static void AttachEffect(string effectName, string spellId, string creatureId, float secondsDelayStart, float enlargeTime, float lifeTime, float shrinkTime, float rotation)
            {
                if (secondsDelayStart > 0)
                {
                    QueueEffect(new WaitingToCast(SpellLocation.Attached, secondsDelayStart, effectName, spellId, creatureId, enlargeTime, lifeTime, null, shrinkTime, rotation));
                    return;
                }

                CreatureBoardAsset creatureBoardAsset = Minis.GetCreatureBoardAsset(creatureId);

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

                AttachEffect(creatureBoardAsset, effectName, spellId, enlargeTime, lifeTime, shrinkTime);
            }
Пример #13
0
            public static bool IsHidden(string creatureId)
            {
                CreatureBoardAsset creatureBoardAsset = Minis.GetCreatureBoardAsset(creatureId);

                if (creatureBoardAsset == null)
                {
                    Log.Error($"IsHidden -- creatureBoardAsset == null");
                    return(false);
                }

                IOldPersistentEffect persistentEffect = creatureBoardAsset.GetPersistentEffect();

                if (persistentEffect == null)
                {
                    Log.Error($"IsHidden -- persistentEffect == null");
                    return(false);
                }

                return(persistentEffect.Hidden);
            }
Пример #14
0
            public static void LaunchProjectile(ProjectileOptions projectileOptions)
            {
                Log.Warning($"------------------------------------------------------------------");
                Log.Debug($"LaunchProjectile:");
                float startTime = Time.time;

                UnityEngine.Random.InitState((int)startTime * 1000);
                Vector3 sourcePosition = Minis.GetHitTargetVector(projectileOptions.taleSpireId);

                int missilesRemaining = projectileOptions.count;

                Log.Debug($"missilesRemaining: {missilesRemaining}");
                lock (lockTrackedProjectiles)
                {
                    LaunchMissiles(projectileOptions, ref startTime, sourcePosition, ref missilesRemaining);
                    while (projectileOptions.kind == ProjectileKind.DistributeAmongAllTargets && missilesRemaining > 0)
                    {
                        LaunchMissiles(projectileOptions, ref startTime, sourcePosition, ref missilesRemaining);
                    }
                }
            }
Пример #15
0
            public static bool IsRotationLocked(string creatureId)
            {
                CreatureBoardAsset creatureBoardAsset = Minis.GetCreatureBoardAsset(creatureId);

                if (creatureBoardAsset == null)
                {
                    Log.Error($"IsRotationLocked -- creatureBoardAsset == null");
                    return(false);
                }

                IOldPersistentEffect persistentEffect = creatureBoardAsset.GetPersistentEffect();

                if (persistentEffect == null)
                {
                    Log.Error($"IsRotationLocked -- persistentEffect == null");
                    return(false);
                }

                //Log.Debug($"persistentEffect.RotationLocked = {persistentEffect.RotationIsLocked}");

                return(persistentEffect.RotationIsLocked);
            }
Пример #16
0
            private static void UpdateTarget()
            {
                if (Time.time - lastTargetTetherUpdateTime <= 0.1)                  // Limit updates to ten times a second.
                {
                    return;
                }

                lastTargetTetherUpdateTime = Time.time;

                if (activeTargetRangeIndicator == null)
                {
                    ActivateTargetRangeIndicator();
                }

                KeepTargetTextFacingCamera();

                CharacterPosition position = Minis.GetPosition(targetAnchorId);

                if (position != null)
                {
                    UpdateTargetDistanceFrom(position);
                }
            }
Пример #17
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));
            }
Пример #18
0
            public static CreatureBoardAsset Set(string creatureId, bool targeted)
            {
                if (string.IsNullOrWhiteSpace(creatureId))
                {
                    return(null);
                }
                Log.Debug($"Target.Set {creatureId}!");
                CreatureBoardAsset creatureBoardAsset = Minis.GetCreatureBoardAsset(creatureId);

                if (creatureBoardAsset != null)
                {
                    if (IsTargeted(creatureBoardAsset) == targeted)
                    {
                        if (targeted)
                        {
                            Log.Warning($"creature {creatureId} is already targeted.");
                        }
                        else
                        {
                            Log.Warning($"creature {creatureId} is already NOT targeted.");
                        }

                        return(creatureBoardAsset);
                    }

                    if (targeted)
                    {
                        AddTargetTo(creatureBoardAsset);
                    }
                    else
                    {
                        RemoveTargetFrom(creatureBoardAsset);
                    }
                }
                return(creatureBoardAsset);
            }
Пример #19
0
            public static CreatureBoardAsset SpinAround(string id)
            {
                if (saveCameraTransform != null)
                {
                    RestoreCamera();
                }

                CreatureBoardAsset targetCreatureBoardAsset = Minis.GetCreatureBoardAsset(id);

                if (targetCreatureBoardAsset == null)
                {
                    return(null);
                }

                CreatureGuid targetCreatureGuid = new CreatureGuid(targetCreatureBoardAsset.Creature.CreatureId.Value);

                targetWorldIdForRestoreCamera = targetCreatureBoardAsset.Creature.CreatureId.Value.ToString();
                CameraController.LookAtCreature(targetCreatureGuid);
                Vector3 targetPosition = targetCreatureBoardAsset.transform.position;

                StartSpinningCamera(targetPosition);

                return(targetCreatureBoardAsset);
            }
Пример #20
0
 static CreatureBoardAsset GetNearestCreature()
 {
     return(Minis.GetCreatureClosestTo(Flashlight.GetPosition(), maxDistanceToNearestCreatureFt));
 }