コード例 #1
0
ファイル: Creature.cs プロジェクト: eldestlady/IB2Toolset
        public Creature DeepCopy()
        {
            Creature other = (Creature)this.MemberwiseClone();

            other.knownSpellsTags = new List <string>();
            foreach (string s in this.knownSpellsTags)
            {
                other.knownSpellsTags.Add(s);
            }
            other.castChances = new List <LocalInt>();
            foreach (LocalInt l in this.castChances)
            {
                LocalInt Lint = new LocalInt();
                Lint.Key   = l.Key;
                Lint.Value = l.Value;
                other.castChances.Add(Lint);
            }

            other.CreatureLocalInts = new List <LocalInt>();
            foreach (LocalInt l in this.CreatureLocalInts)
            {
                LocalInt Lint = new LocalInt();
                Lint.Key   = l.Key;
                Lint.Value = l.Value;
                other.CreatureLocalInts.Add(Lint);
            }
            other.CreatureLocalStrings = new List <LocalString>();
            foreach (LocalString l in this.CreatureLocalStrings)
            {
                LocalString Lstr = new LocalString();
                Lstr.Key   = l.Key;
                Lstr.Value = l.Value;
                other.CreatureLocalStrings.Add(Lstr);
            }
            other.RequiredWeaponTypesToHarmCreature = new List <LocalString>();
            foreach (LocalString l in this.RequiredWeaponTypesToHarmCreature)
            {
                LocalString Lstr = new LocalString();
                Lstr.Key   = l.Key;
                Lstr.Value = l.Value;
                other.RequiredWeaponTypesToHarmCreature.Add(Lstr);
            }
            //other.EffectsList = new Effects();
            //other.onScoringHit = this.onScoringHit.DeepCopy();
            return(other);
        }
コード例 #2
0
ファイル: IconSprite.cs プロジェクト: grannypron/IB2Toolset
        private void cbxKnownSpells_ItemCheck(object sender, ItemCheckEventArgs e)
        {
            //A nice trick to deal with events that you cannot process when they are raised is to delay
            //the processing. Which you can do with the Control.BeginInvoke() method, it runs as soon
            //as all events are dispatched, side-effects are complete and the UI thread goes idle again.
            //http://stackoverflow.com/questions/4454058/no-itemchecked-event-in-a-checkedlistbox/4454594#4454594
            //
            this.BeginInvoke((MethodInvoker) delegate
            {
                if (!refreshingList)
                {
                    string _nodeTag = prntForm.lastSelectedCreatureNodeName;
                    int index       = prntForm.frmBlueprints.GetCreatureIndex(_nodeTag);
                    if (index >= 0)
                    {
                        Creature crt = prntForm.creaturesList[index];
                        crt.knownSpellsTags.Clear();
                        foreach (object itemChecked in cbxKnownSpells.CheckedItems)
                        {
                            Spell chkdSpell = (Spell)itemChecked;
                            crt.knownSpellsTags.Add(chkdSpell.tag);

                            //set up castChances (list of LoacalInt)
                            //TODO handle situation if spells are removed
                            bool foundSpellAlready = false;
                            foreach (LocalInt lint in crt.castChances)
                            {
                                if (lint.Key == chkdSpell.tag)
                                {
                                    foundSpellAlready = true;
                                    break;
                                }
                            }

                            if (!foundSpellAlready)
                            {
                                LocalInt castChanceItem = new LocalInt();
                                castChanceItem.Key      = chkdSpell.tag;
                                castChanceItem.Value    = 0;
                                crt.castChances.Add(castChanceItem);
                            }
                        }
                        //remove cast canches from list if their key is not contained in list with knwon spell tags
                        for (int i = crt.castChances.Count - 1; i >= 0; i--)
                        {
                            bool spellIsKnown = false;
                            foreach (string s in crt.knownSpellsTags)
                            {
                                if (crt.castChances[i].Key == s)
                                {
                                    spellIsKnown = true;
                                    break;
                                }
                            }
                            if (!spellIsKnown)
                            {
                                crt.castChances.RemoveAt(i);
                            }
                        }
                    }
                }
            });
        }
コード例 #3
0
ファイル: Creature.cs プロジェクト: slowdive-fan/IB2Toolset
 public Creature DeepCopy()
 {
     Creature other = (Creature)this.MemberwiseClone();
     other.knownSpellsTags = new List<string>();
     foreach (string s in this.knownSpellsTags)
     {
         other.knownSpellsTags.Add(s);
     }
     other.CreatureLocalInts = new List<LocalInt>();
     foreach (LocalInt l in this.CreatureLocalInts)
     {
         LocalInt Lint = new LocalInt();
         Lint.Key = l.Key;
         Lint.Value = l.Value;
         other.CreatureLocalInts.Add(Lint);
     }
     other.CreatureLocalStrings = new List<LocalString>();
     foreach (LocalString l in this.CreatureLocalStrings)
     {
         LocalString Lstr = new LocalString();
         Lstr.Key = l.Key;
         Lstr.Value = l.Value;
         other.CreatureLocalStrings.Add(Lstr);
     }
     //other.EffectsList = new Effects();
     //other.onScoringHit = this.onScoringHit.DeepCopy();
     return other;
 }
コード例 #4
0
ファイル: Prop.cs プロジェクト: slowdive-fan/IB2Toolset
 public Prop DeepCopy()
 {
     Prop other = (Prop)this.MemberwiseClone();
     other.PropLocalInts = new List<LocalInt>();
     foreach (LocalInt l in this.PropLocalInts)
     {
         LocalInt Lint = new LocalInt();
         Lint.Key = l.Key;
         Lint.Value = l.Value;
         other.PropLocalInts.Add(Lint);
     }
     other.PropLocalStrings = new List<LocalString>();
     foreach (LocalString l in this.PropLocalStrings)
     {
         LocalString Lstr = new LocalString();
         Lstr.Key = l.Key;
         Lstr.Value = l.Value;
         other.PropLocalStrings.Add(Lstr);
     }
     other.WayPointList = new List<WayPoint>();
     foreach (WayPoint coor in this.WayPointList)
     {
         other.WayPointList.Add(coor.DeepCopy());
     }
     return other;
 }