Esempio n. 1
0
 void Start()
 {
     if (!UIEvents.isInitialized)
     {
         UIEvents.InitializeEvents(this);
         isUsed = true;
         Debug.Log("Using backup debug ui for main ui events... consider using a custom one as this is not performance friendly or complete!");
     }
 }
Esempio n. 2
0
 public static void QuitToMainMenu(bool overrideConfirm = false)
 {
     if (overrideConfirm)
     {
         _QuitToMainMenu();
         return;
     }
     UIEvents.ShowConfirmationPopup("Are You Sure You Want To Quit To Main Menu?\nAny Unsaved Progress Will Be Lost!", _QuitToMainMenu);
 }
Esempio n. 3
0
 public static void StartNewGame(bool overrideConfirm = false)
 {
     if (overrideConfirm || isInMainMenuScene)
     {
         _StartNewGame();
         return;
     }
     UIEvents.ShowConfirmationPopup("Are You Sure You Want To Start A New Game?\nAny Unsaved Progress Will Be Lost!", _StartNewGame);
 }
Esempio n. 4
0
        public static void LoadGame(int slot, bool overrideConfirm = false)
        {
            if (overrideConfirm || GameManager.isInMainMenuScene)
            {
                _LoadGame(slot);
                return;
            }
            string msg = "Are You Sure You Want Load Save Slot " + slot + "?\nAny Unsaved Progress Will Be Lost!";

            UIEvents.ShowConfirmationPopup(msg, () => _LoadGame(slot));
        }
Esempio n. 5
0
        public static void QuitApplication(bool overrideConfirm = false)
        {
            if (overrideConfirm)
            {
                _QuitApplication();
                return;
            }

            string msg = "Are You Sure You Want To Quit To Desktop?";

            if (!isInMainMenuScene)
            {
                msg += "\nAny Unsaved Progress Will Be Lost!";
            }

            UIEvents.ShowConfirmationPopup(msg, _QuitApplication);
        }
Esempio n. 6
0
        public static void TriggerEffects(GameEffectCollection effects, DynamicObject caster, Vector3 pos, DynamicObject obj, bool isCast, bool isFromRadiusRecast = false)
        {
            ModifierEntryPoints casterEntryPoints = null;

            if (caster != null)
            {
                casterEntryPoints = caster.GetObjectScript <ModifierEntryPoints>();
            }

            EffectContext context = isCast ? effects.cast : effects.dispell;

            float radius = context.radius;

            if (!isFromRadiusRecast && radius > 0)
            {
                if (casterEntryPoints != null)
                {
                    radius = casterEntryPoints.ModifyValue("EffectRadius", radius, new Dictionary <string, object>()
                    {
                        { "Caster", caster }, { "EffectCollection", effects }
                    });
                }

                RetriggerEffectsForArea(effects, caster, pos, radius, context.mask, context.checkLOSOnRadiusCast, isCast);
                return;
            }

            if (obj == null)
            {
                return;
            }

            GameEffectsHandler targetEffectsHandler = obj.GetObjectScript <GameEffectsHandler>();

            if (targetEffectsHandler != null && targetEffectsHandler.IsAffectedBy(effects))
            {
                return;
            }

            Dictionary <string, object> epRunSubjects = new Dictionary <string, object>()
            {
                { "Caster", caster }, { "AffectedObject", obj }, { "EffectCollection", effects }, { "Effect", null }
            };
            Dictionary <string, object> runSubjects = new Dictionary <string, object>()
            {
                { "Caster", caster }, { "AffectedObject", obj }
            };

            List <GameEffect> effectsToHold = new List <GameEffect>();
            List <float>      magnitudes    = new List <float>();
            List <float>      durations     = new List <float>();

            for (int i = 0; i < context.effects.Length; i++)
            {
                GameEffectItem effectItem = context.effects[i];
                GameEffect     effect     = effectItem.effect;

                if (effect.PlayerOnly() && !obj.isPlayer)
                {
                    continue;
                }

                bool needsToBeAdded = effect.AddToEffectsList();

                if (needsToBeAdded)
                {
                    if (isCast)
                    {
                        if (targetEffectsHandler == null)
                        {
                            Debug.LogWarning("'" + obj.name + "' Doesnt have a GameEffectsHandler, and game effect '" + effect.name + " Needs To Be Kept In An Effect Handler List");
                            continue;
                        }
                    }
                    else
                    {
                        Debug.LogWarning("Game effect '" + effect.name + " Needs To Be Kept In An Effect Handler List, So It Cant Be Used As a Dispell Effect....");
                        continue;
                    }
                }
                if (!effect.EffectValid(caster, obj))
                {
                    continue;
                }

                if (!Conditions.ConditionsMet(effectItem.conditions, runSubjects))
                {
                    continue;
                }
                if (!Conditions.ConditionsMet(effect.conditions, runSubjects))
                {
                    continue;
                }

                float magnitude = effectItem.magnitude;
                float duration  = effectItem.duration;
                if (casterEntryPoints != null)
                {
                    epRunSubjects["Effect"] = effectItem.effect;
                    magnitude = casterEntryPoints.ModifyValue("EffectMagnitude", magnitude, epRunSubjects);
                    if (duration > 0)
                    {
                        duration = casterEntryPoints.ModifyValue("EffectDuration", duration, epRunSubjects);
                    }
                }


                /*
                 *  TODO: figure out garbage created by create copy
                 */
                // if dispell we should already be out by now if needsToBeAdded...
                if (needsToBeAdded && effect.CreateCopy())
                {
                    effect = Object.Instantiate(effect);
                }

                // in case there was a problem with the effect start
                // return out before we add the effect possibly
                if (!effect.OnEffectStart(caster, obj, magnitude, duration))
                {
                    continue;
                }

                if (needsToBeAdded)
                {
                    effectsToHold.Add(effect);
                    magnitudes.Add(magnitude);
                    durations.Add(duration);
                }
            }

            if (effectsToHold.Count > 0)
            {
                targetEffectsHandler.AddEffectsToList(effects, caster, effectsToHold, magnitudes, durations);
            }

            // TODO: choose scheme for msg...
            if (obj.isPlayer)
            {
                if (!string.IsNullOrEmpty(context.message))
                {
                    UIEvents.ShowMessage(0, context.message, false, UIColorScheme.Normal, false);
                }
            }
        }