Ejemplo n.º 1
0
 void GenerateSymbols()
 {
     for (var i = 0; i < SymbolCount; i++)
     {
         AddSymbol(symbolProvider.GetSymbol());
     }
 }
Ejemplo n.º 2
0
        private static void AppendOutput(IEnumerable <OutputEntry> entries, StringBuilder builder, ISymbolProvider symbolProvider)
        {
            var entriesList = entries.ToList();

            if (entriesList.Count != 0)
            {
                builder.AppendLine().AppendLine("Output:");
                entriesList.ForEach(x => builder.Append($"{symbolProvider.GetSymbol(x.Type)} {x.Message}\r\n"));
            }
        }
Ejemplo n.º 3
0
        private void AppendOperations(IEnumerable <IOperationResult> results, StringBuilder builder)
        {
            builder.AppendLine("Operations:");
            foreach (var result in results)
            {
                if (result is FillingOperationResult)
                {
                    builder.AppendLine(".. InnerOperations ..");
                    continue;
                }

                builder.AppendFormat("{0} {1}", _symbolProvider.GetSymbol(result.State), result.Text);

                if (result.Exception != null)
                {
                    builder.AppendFormat(" ({0})", result.Exception.Name);
                }

                builder.Append("\r\n");
            }
        }
Ejemplo n.º 4
0
    IEnumerator AddSymbols()
    {
        GameObject currentSymbol = null;

        yield return(new WaitForSeconds(Random.Range(0, StartDelayRandomMax)));

        for (int i = 0; i < MaxSymbols; i++)
        {
            currentSymbol = AddFallingSymbol(symbolProvider.GetSymbol());
            yield return(new WaitForSeconds(DelayBetweenSymbols));
        }

        yield return(new WaitForSeconds(2));

        OnLastSymbolFade(null);
        //currentSymbol.GetComponent<FallingSymbol>().OnFade -= OnLastSymbolFade;
        //currentSymbol.GetComponent<FallingSymbol>().OnFade += OnLastSymbolFade;
    }
Ejemplo n.º 5
0
        private static void AppendOperations(IEnumerable <IOperationResult> results, StringBuilder builder, ISymbolProvider symbolProvider)
        {
            builder.AppendLine("Operations:");
            foreach (var result in results)
            {
                if (result is FillingOperationResult)
                {
                    builder.AppendLine(".. InnerOperations ..");
                    continue;
                }

                builder.Append($"{symbolProvider.GetSymbol(result.State)} {result.Text}");

                if (result.Exception != null)
                {
                    builder.Append($" ({result.Exception.Name})");
                }

                builder.Append("\r\n");
            }
        }
Ejemplo n.º 6
0
        public LocationInfo GetLocationInfo(string word, int lineIndex)
        {
            LocationInfo location = new LocationInfo();

            int arraySeparatorIndex = word.IndexOf("+");

            if (arraySeparatorIndex >= 0)
            {
                int index;
                if (int.TryParse(word.Substring(arraySeparatorIndex + 1), out index))
                {
                    location.ArrayIndex = index;
                }
                word = word.Substring(0, arraySeparatorIndex);
            }

            if (_provider is SymbolCodeDataProvider && _symbolProvider != null)
            {
                int rangeStart, rangeEnd;
                GetSymbolByteRange(lineIndex, out rangeStart, out rangeEnd);
                location.Symbol = _symbolProvider.GetSymbol(word, rangeStart, rangeEnd);
            }

            location.Label = LabelManager.GetLabel(word);

            int address;

            if (location.Label != null)
            {
                address = location.Label.GetRelativeAddress(this.CpuType).Address;
                if (address >= 0)
                {
                    location.Address = location.Label.GetRelativeAddress(this.CpuType).Address + (location.ArrayIndex ?? 0);
                }
                else
                {
                    location.Address = -1;
                }
            }
            else if (word.StartsWith("$"))
            {
                word = word.Replace("$", "");
                if (Int32.TryParse(word, System.Globalization.NumberStyles.HexNumber, null, out address))
                {
                    location.Address = GetFullAddress(address, word.Length);
                }
            }
            else if (Int32.TryParse(word, out address))
            {
                location.Address = (int)address;
            }
            else
            {
                location.Address = -1;
            }

            if (location.Label == null && location.Address >= 0)
            {
                AddressInfo relAddress = new AddressInfo()
                {
                    Address = location.Address, Type = RelativeMemoryType
                };
                CodeLabel label = LabelManager.GetLabel(relAddress);
                if (label != null && !string.IsNullOrWhiteSpace(label.Label))
                {
                    //ignore comment-only labels
                    location.Label = label;
                }
            }

            if (location.Label != null && location.Address >= 0)
            {
                AddressInfo absAddress        = location.Label.GetAbsoluteAddress();
                AddressInfo absIndexedAddress = DebugApi.GetAbsoluteAddress(new AddressInfo()
                {
                    Address = location.Address, Type = RelativeMemoryType
                });
                if (absIndexedAddress.Address > absAddress.Address)
                {
                    location.ArrayIndex = absIndexedAddress.Address - absAddress.Address;
                }
            }

            return(location);
        }
Ejemplo n.º 7
0
        public void ShowFieldState(List <IAnimal> animals)
        {
            _stringDrawer.FillRectWithSymbol(INDENT_HORIZONTAL, INDENT_VERTICAL,
                                             _field.Size.X, _field.Size.Y, Constants.EMPTY_SYMBOL);

            foreach (var animal in animals)
            {
                _stringDrawer.PutSymbol(INDENT_HORIZONTAL + animal.Position.X, INDENT_VERTICAL + animal.Position.Y, _animalSymbolProvider.GetSymbol(animal.GetType()));
            }

            _consoleOutput.Clear();
            _consoleOutput.Write(_fieldAsStringBuilder.ToString());
        }