Example #1
0
 private void AddUsedBy(string path)
 {
     if (UsedBy.Contains(path))
     {
         return;
     }
     UsedBy.Add(path);
     m_FilteredUsedBy = null;
 }
Example #2
0
 public void DrawEffect(SpriteBatch spriteBatch, Effects effect, UsedBy on)
 {
     foreach (Effect e in activeEffects)
     {
         if (e.effect == effect)
         {
             e.Draw(spriteBatch, on);
         }
     }
 }
        public void Draw(SpriteBatch spriteBatch, UsedBy by)
        {
            if (by == UsedBy.enemy)
            {
                spriteFx = SpriteEffects.FlipHorizontally;
                position = new Vector2(700, 300);
            }
            else
            {
                position = new Vector2(325, 300); spriteFx = SpriteEffects.None;
            }

            switch (usedAbility)
            {
            case UsedAbility.Hit:
                texture = textures.hitAnimation;
                break;

            case UsedAbility.Magic:
                texture = textures.magicAnimation;
                break;

            case UsedAbility.Defence:
                texture  = textures.defenceAnimation;
                spriteFx = SpriteEffects.None;
                break;

            case UsedAbility.Dodge:
                texture = textures.dodgeAnimation;
                break;

            case UsedAbility.PoisonHit:
                texture = textures.poisonHitAnimation;
                break;

            case UsedAbility.Miss:
                texture = textures.missAnimation;
                break;

            case UsedAbility.confusion:
                texture  = textures.confusion;
                spriteFx = SpriteEffects.None;
                break;
            }

            try
            {
                spriteBatch.Draw(texture, position, srcRec, Color.White, 0,
                                 new Vector2(), 10, spriteFx, 1);
            }
            catch { }
        }
Example #4
0
            private List <string> GetFilteredUsing(bool showProgress)
            {
                // Grab all the references.
                HashSet <string> childPaths = new HashSet <string>(Using);

                for (int i = 0; i < Using.Count; i++)
                {
                    string path = Using[i];

                    // Avoid infinite loops where assets reference each other.
                    if (UsedBy.Contains(path))
                    {
                        if (childPaths.Contains(path))
                        {
                            childPaths.Remove(path);
                        }
                        continue;
                    }

                    UsageInfo info = GetUsageInfo(path);

                    // Only show progress if there is a significant number of sub-paths to search through.
                    if (showProgress && (info.Using.Count > 20) && EditorUtility.DisplayCancelableProgressBar("Gathering Child File References for " + FileName, path, i * 1f / Using.Count))
                    {
                        EditorUtility.ClearProgressBar();
                        return(new List <string>());
                    }

                    // Go through each sub path and remove any found in childPaths.
                    foreach (string subPath in info.Using)
                    {
                        if (childPaths.Contains(subPath))
                        {
                            childPaths.Remove(subPath);
                        }
                    }
                }

                if (showProgress)
                {
                    EditorUtility.ClearProgressBar();
                }

                // Return final child paths as an ordered list.
                return(childPaths.ToList());
            }
 public void AddEffect(Effects effect, UsedBy user)
 {
     if (user == UsedBy.player)
     {
         if (effect == Effects.bleed)
         {
             enemy.stats.AddEffect(player.stats.CheckStat(Stat.strength) /
                                   player.stats.CheckStat(Stat.accuracy) / 2, player.abilities.effect,
                                   player.stats.CheckStat(Stat.level) + player.stats.CheckStat(Stat.strength) / 2);
         }
         else if (effect == Effects.poison)
         {
             enemy.stats.AddEffect(rand.Next(Math.Min((player.stats.CheckStat(Stat.intelligence) / 5) + (player.stats.CheckStat(Stat.luck) / 10),
                                                      (player.stats.CheckStat(Stat.intelligence) / 2) - 1), (player.stats.CheckStat(Stat.intelligence) / 2)),
                                   player.abilities.effect, player.stats.CheckStat(Stat.intelligence));
         }
         else if (effect == Effects.confusion)
         {
             enemy.stats.AddEffect(player.stats.CheckStat(Stat.intelligence) / 4,
                                   player.abilities.effect, player.stats.CheckStat(Stat.intelligence));
         }
     }
     else
     {
         if (effect == Effects.bleed)
         {
             player.stats.AddEffect(enemy.stats.CheckStat(Stat.strength) /
                                    enemy.stats.CheckStat(Stat.accuracy) / 2, enemy.ability.effect,
                                    enemy.stats.CheckStat(Stat.level) + enemy.stats.CheckStat(Stat.strength) / 2);
         }
         else if (effect == Effects.poison)
         {
             player.stats.AddEffect(rand.Next(Math.Min((enemy.stats.CheckStat(Stat.intelligence) / 5) + (enemy.stats.CheckStat(Stat.luck) / 10),
                                                       (enemy.stats.CheckStat(Stat.intelligence) / 2) - 1), (enemy.stats.CheckStat(Stat.intelligence) / 2)),
                                    enemy.ability.effect, enemy.stats.CheckStat(Stat.intelligence));
         }
         else if (effect == Effects.confusion)
         {
             player.stats.AddEffect(enemy.stats.CheckStat(Stat.intelligence) / 4,
                                    enemy.ability.effect, enemy.stats.CheckStat(Stat.intelligence));
         }
     }
 }
Example #6
0
        public void NotifyElementChanged()
        {
            if (_ignoreNotifyElementChanged)
            {
                return;
            }
            if (UsedBy.Count > 0)
            {
                var copyOfUsedBy = new List <Expression>(UsedBy);
                UsedBy.Clear();
                foreach (var e in copyOfUsedBy)
                {
                    var ae = e as ArrayExpression;
                    ae?.SetRawExpression(ae.ExprString, Exprs.Length);
                    e.Recalculate();
                }
            }

            ValueChanged?.Invoke(this, EventArgs.Empty);
        }
Example #7
0
        public override void Recalculate(int depth = 1)
        {
            if (depth > MaxRecursionDepth)
            {
                // we are proabaly about to encounter a stack overflow
                return;
            }
            // remove all the DependentOn values
            // e.g. remove the cross-references
            foreach (var e in DependentOn)
            {
                e.UsedBy.Remove(this);
            }
            DependentOn.Clear();

            try
            {
                var val = Evaluater.Evaluate(ExprString, VarEval, IndexInArray);
                CachedValue.SwitchTo(val.IsArray ? val.AsArray[IndexInArray] : val);
            }
            catch
            {
                StepManager.ErrorOccurred = true;
            }

            if (!IsWeak)
            {
                if (UsedBy.Count > 0)
                {
                    var copyOfUsedBy = new List <Expression>(UsedBy);
                    UsedBy.Clear();
                    foreach (var e in copyOfUsedBy)
                    {
                        e.Recalculate(depth + 1);
                    }
                }
                ParentArray?.NotifyElementChanged();
            }
            ValueChanged?.Invoke(this, EventArgs.Empty);
        }
        // if there is a animation for the effect it will happen here
        public void Draw(SpriteBatch spriteBatch, UsedBy on)
        {
            Vector2 position;

            if (on == UsedBy.enemy)
            {
                position = new Vector2(800, 150);
            }
            else
            {
                position = new Vector2(325, 200);
            }

            switch (effect)
            {
            case Effects.poison:
                texture = textures.poisonIcon;
                break;

            case Effects.bleed:
                texture = textures.bleedIcon;
                break;

            case Effects.confusion:
                texture = textures.confusionIcon;
                break;

            case Effects.none:
                texture = null;
                break;
            }

            try
            {
                spriteBatch.Draw(texture, position, new Rectangle(0, 0, 16, 16), Color.White, 0,
                                 new Vector2(), 8, SpriteEffects.None, 1);
            }
            catch   {  }
        }
Example #9
0
 public bool HasUsedBy(string path)
 {
     return(UsedBy.Contains(path));
 }
Example #10
0
            public void OnGUI()
            {
                if (Path.IsNullOrEmpty())
                {
                    return;
                }

                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                GUILayout.BeginVertical();
                GUILayout.Space(5);
                GUILayout.Label(Directory, DirectoryStyle);
                GUILayout.EndVertical();
                GUILayout.Label(FileName, FileNameStyle);
                if (GUILayout.Button("Refresh"))
                {
                    Refresh();
                }
                if (GUILayout.Button("Reset All"))
                {
                    ResetAll();
                }
                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();

                float width = Instance.position.width - 10;

                GUILayout.BeginVertical(GUILayout.Width(width / 2));

                GUILayout.Label("Used by:");
                m_UsedByScroll = GUILayout.BeginScrollView(m_UsedByScroll, GUIStyle.none);
                if (Instance.m_ShowIndirectReferences)
                {
                    UsedBy.OrderBy(p => p).ForEach(OnButtonGUI);
                }
                else
                {
                    FilteredUsedBy.OrderBy(p => p).ForEach(OnButtonGUI);
                }
                if (GUILayout.Button(Instance.m_Scanned ? "Refresh All..." : "Find All..."))
                {
                    PopulateAllReferences();
                }
                GUILayout.EndScrollView();
                GUILayout.EndVertical();

                GUILayout.BeginVertical(GUILayout.Width(width / 2));
                GUILayout.Label("Using:");
                m_UsesScroll = GUILayout.BeginScrollView(m_UsesScroll, GUIStyle.none);
                if (Instance.m_ShowIndirectReferences)
                {
                    Using.OrderBy(p => p).ForEach(OnButtonGUI);
                }
                else
                {
                    GetFilteredUsingWithProgress().OrderBy(p => p).ForEach(OnButtonGUI);
                }
                GUILayout.EndScrollView();
                GUILayout.EndVertical();

                GUILayout.EndHorizontal();
            }
Example #11
0
 private bool CanShow(string path)
 {
     return(!path.IsNullOrEmpty() && (path != Path) && !UsedBy.Contains(path));
 }
Example #12
0
 public void AddUsedBy(IEnumerable <MemberInfo> m)
 {
     lock (usedByLock) UsedBy.AddRange(m);
 }
 public Abilities(UsedBy usedBy, TextureManager textures)
 {
     this.usedBy   = usedBy;
     this.textures = textures;
 }
Example #14
0
 public CiPopupText(UsedBy usedy, EventHandler onHiddenOrDestroyed = null)
 {
     _usedBy = usedy;
     _onHiddenOrDestroyed = onHiddenOrDestroyed;
 }
Example #15
0
        public void OnGUI()
        {
            if (m_Targets == null || m_Targets.Length == 0)
            {
                return;
            }

            float width       = AssetUsageWindow.Instance.position.width - 10;
            int   columns     = Mathf.Clamp((int)(width / 100), 1, m_Targets.Length);
            float columnWidth = (width + 8) / columns;

            GUILayout.Label(m_Guids.Length != 1 ? "Selected Assets x" + m_Guids.Length.ToString("N0") : "Selected Asset", EditorStyles.boldLabel);

            GUILayout.BeginHorizontal();

            for (int i = 0; i < Targets.Length; i++)
            {
                Object target = Targets[i];
                Object obj    = EditorGUILayout.ObjectField(target, typeof(Object), false, GUILayout.Width(columnWidth - 4));

                if (obj != target)
                {
                    Object[] copy = Targets.ToArray();
                    copy[i]           = obj;
                    Selection.objects = copy;
                }

                if (i % columns == columns - 1)
                {
                    GUILayout.EndHorizontal();
                    GUILayout.BeginHorizontal();
                }
            }

            GUILayout.EndHorizontal();

            if (m_Guids.Length == 0)
            {
                GUILayout.Label("Nothing selected.", EditorStyles.boldLabel);
                return;
            }

            if (m_Guids.Length > 997)
            {
                GUILayout.Label("Too many file IDs selected. (" + m_Guids.Length.ToString("N0") + "/900 max)", EditorStyles.boldLabel);
                return;
            }

            GUILayout.BeginHorizontal();

            GUILayout.BeginVertical(GUILayout.Width(width / 2));

            GUILayout.Label("Referenced by " + UsedBy.Count.ToString("N0") + (UsedBy.Count != 1 ? " assets:" : " asset:"));
            m_UsedByScroll = GUILayout.BeginScrollView(m_UsedByScroll, GUIStyle.none);
            UsedBy.ForEach(OnAssetButtonGUI);

            CleanUsedByInScene();

            if (UsedByInScene.Count > 0)
            {
                EditorGUILayout.Space();
                GUILayout.Label("References in Hierarchy:");
                UsedByInScene.ForEach(OnHierarchyObjectButtonGUI);
            }

            GUILayout.EndScrollView();

            if (GUILayout.Button("Select all"))
            {
                Object[] selection = new Object[UsedBy.Count];

                for (int index = 0; index < selection.Length; index++)
                {
                    selection[index] = AssetDatabase.LoadAssetAtPath <Object>(UsedBy[index].Path);
                }

                Selection.objects = selection;
                EditorGUIUtility.PingObject(Selection.activeObject);
            }

            GUILayout.EndVertical();

            GUILayout.BeginVertical(GUILayout.Width(width / 2));
            GUILayout.Label("Referencing " + Using.Count.ToString("N0") + (Using.Count != 1 ? " assets:" : " asset:"));
            m_UsesScroll = GUILayout.BeginScrollView(m_UsesScroll, GUIStyle.none);
            Using.ForEach(OnAssetButtonGUI);
            GUILayout.EndScrollView();

            if (GUILayout.Button("Select all"))
            {
                Object[] selection = new Object[Using.Count];

                for (int index = 0; index < selection.Length; index++)
                {
                    selection[index] = AssetDatabase.LoadAssetAtPath <Object>(Using[index].Path);
                }

                Selection.objects = selection;
                EditorGUIUtility.PingObject(Selection.activeObject);
            }
            GUILayout.EndVertical();

            GUILayout.EndHorizontal();
        }
Example #16
0
 public CiPopupHtml(UsedBy usedy, Action <bool> onHiddenOrDestroyed = null)
 {
     _usedBy = usedy;
     _onHiddenOrDestroyed = onHiddenOrDestroyed;
 }
Example #17
0
 public void AddUsedBy(MemberInfo m)
 {
     lock (usedByLock) UsedBy.Add(m);
 }