Esempio n. 1
0
 public bool Tick()
 {
     foreach (Pointer pointer in pointers)
     {
         bool delaying = pointer.GetDelayAmt() > 0;
         bool skipping = pointer.isSkipping(true);
         pointer.Execute();
         if (pointer.GetReadType() == Pointer.ReadType.EXECUTE)
         {
             if (pointer.position.x >= runes.GetLength(0) || pointer.position.y >= runes.GetLength(1))
             {
                 pointer.DeductMana(pointer.GetMana());
             }
             else if (skipping || delaying || runes[pointer.position.x, pointer.position.y].Execute(pointer, this))
             {
                 AdvancePointer(pointer, !delaying && !skipping);
             }
         }
         else if (pointer.GetReadType() == Pointer.ReadType.READ_NUM)
         {
             IExecutableRune r = runes[pointer.position.x, pointer.position.y];
             if (r is RuneNumber)
             {
                 int j = 0;
                 int n = ((RuneNumber)r).value;
                 if (pointer.GetStackSize() > 0)
                 {
                     object o = pointer.Pop();
                     if (o is ValueType && MathHelper.IsInteger((ValueType)o))
                     {
                         j = (int)MathHelper.GetValue((ValueType)o);
                     }
                 }
                 pointer.Push(j * 10 + n);
                 AdvancePointer(pointer, false);
             }
             else
             {
                 pointer.SetReadType(Pointer.ReadType.EXECUTE);
             }
         }
         else if (pointer.GetReadType() == Pointer.ReadType.READ_CHAR)
         {
             char c = RuneRegistry.GetRuneChar(runes[pointer.position.x, pointer.position.y]);
             pointer.Push(c);
             c = modifiers[pointer.position.x, pointer.position.y];
             if (c != ' ')
             {
                 pointer.Push(c);
             }
             pointer.SetReadType(Pointer.ReadType.EXECUTE);
             AdvancePointer(pointer, false);
         }
         else if (pointer.GetReadType() == Pointer.ReadType.READ_CHAR_CONTINUOUS)
         {
             char c = RuneRegistry.GetRuneChar(runes[pointer.position.x, pointer.position.y]);
             if (c.Equals('`'))
             {
                 pointer.SetReadType(Pointer.ReadType.EXECUTE);
             }
             else
             {
                 pointer.Push(c);
                 c = modifiers[pointer.position.x, pointer.position.y];
                 if (c != ' ')
                 {
                     pointer.Push(c);
                 }
             }
             AdvancePointer(pointer, false);
         }
         else if (pointer.GetReadType() == Pointer.ReadType.READ_STR)
         {
             char c = RuneRegistry.GetRuneChar(runes[pointer.position.x, pointer.position.y]);
             if (c.Equals('\"'))
             {
                 pointer.SetReadType(Pointer.ReadType.EXECUTE);
                 AdvancePointer(pointer, true);
             }
             else
             {
                 object o = pointer.GetStackSize() > 0 ? pointer.Pop() : null;
                 if (o is string || o == null)
                 {
                     string s = (string)o + c;
                     c = modifiers[pointer.position.x, pointer.position.y];
                     if (c != ' ')
                     {
                         s += c;
                     }
                     pointer.Push(s);
                 }
                 else
                 {
                     pointer.Push(o);
                     string s = c.ToString();
                     c = modifiers[pointer.position.x, pointer.position.y];
                     if (c != ' ')
                     {
                         s += c;
                     }
                     pointer.Push(s);
                 }
                 AdvancePointer(pointer, false);
             }
         }
     }
     pointers.ForEach(x =>
     {
         int xi = pointers.IndexOf(x);
         pointers.ForEach(y =>
         {
             int yi = pointers.IndexOf(y);
             if (xi < yi && x.position == y.position && x.direction == y.direction)
             {
                 x.Merge(y);
                 y.DeductMana(y.GetMana());
             }
         });
     });
     pointers.ForEach(x =>
     {
         if (x.GetMana() >= 100 && runes[x.position.x, x.position.y] != RuneRegistry.GetRune(' '))
         {
             runes[x.position.x, x.position.y] = RuneRegistry.GetRune(' ');
             x.DeductMana(x.GetMana() / 2);
             Console.Error.WriteLine("Warning: rune at " + x.position + " has burned out!");
         }
     });
     pointers.ForEach(x =>
     {
         if (modifiers[x.position.x, x.position.y] == '̺' || modifiers[x.position.x, x.position.y] == '̪')
         {
             if (x.GetStackSize() > x.GetMana() + 10)
             {
                 TruncateStack(x, modifiers[x.position.x, x.position.y] == '̪');
             }
         }
     });
     pointers.ForEach(x =>
     {
         if (x.GetStackSize() > x.GetMana() + 10)
         {
             x.DeductMana(1);
         }
     });
     pointers.AddRange(newpointers);
     newpointers.Clear();
     pointers.RemoveAll(x => x.GetMana() <= 0);
     return(pointers.Count > 0);
 }
Esempio n. 2
0
 public char GetRune(int x, int y)
 {
     return(RuneRegistry.GetRuneChar(runes[x, y]));
 }