Exemplo n.º 1
0
        public ArtistsSummary GetArtists(string artistFileName, int pageNo, int pageSize)
        {
            if (string.IsNullOrEmpty(artistFileName))
            {
                throw new ArgumentNullException(nameof(artistFileName));
            }
            if (pageSize == 0)
            {
                throw new ArgumentException("Pagesize 0 not supported.");
            }
            var artists        = IoManager.ReadWithMapper <ArtistNode, ArtistNodeMap>(artistFileName);
            var artistsSummary = new ArtistsSummary
            {
                PageInfo = new PageInfo
                {
                    PageNumber         = pageNo,
                    PageSize           = pageSize,
                    TotalNumberOfPages = artists.Count / pageSize
                },
                ArtistsSummaries = artists.Where(a => a.ArtistInCollection)
                                   .Skip(pageNo * pageSize)
                                   .Take(pageSize)
                                   .Select(a => new ArtistSummary
                {
                    Id                = a.ArtistId,
                    ArtistType        = a.ArtistLabel,
                    Name              = a.Name,
                    ValidatedManually = a.ManualValidated
                }).ToArray()
            };

            return(artistsSummary);
        }
Exemplo n.º 2
0
        public async Task InitializeAsync(string workFolderPath, Network network, string operationName, CancellationToken cancel)
        {
            using (BenchmarkLogger.Measure(operationName: operationName))
            {
                WorkFolderPath = Guard.NotNullOrEmptyOrWhitespace(nameof(workFolderPath), workFolderPath, trim: true);
                Network        = Guard.NotNull(nameof(network), network);

                var transactionsFilePath = Path.Combine(WorkFolderPath, "Transactions.dat");

                // In Transactions.dat every line starts with the tx id, so the first character is the best for digest creation.
                TransactionsFileManager = new IoManager(transactionsFilePath);

                cancel.ThrowIfCancellationRequested();
                using (await TransactionsFileAsyncLock.LockAsync(cancel).ConfigureAwait(false))
                {
                    IoHelpers.EnsureDirectoryExists(WorkFolderPath);
                    cancel.ThrowIfCancellationRequested();

                    if (!TransactionsFileManager.Exists())
                    {
                        await SerializeAllTransactionsNoLockAsync().ConfigureAwait(false);

                        cancel.ThrowIfCancellationRequested();
                    }

                    await InitializeTransactionsNoLockAsync(cancel).ConfigureAwait(false);
                }
            }
        }
Exemplo n.º 3
0
        public TestState() : base()
        {
            IoManager.Clear();
            WorldView tm;

            Simulator.Instance.Initialize(out tm);
        }
Exemplo n.º 4
0
        private void ScanTypographicalSymbol(string currentCharacter)
        {
            if (!Constants.Constants.PrefixSymbols.Contains(currentCharacter))
            {
                CurrentToken.Symbol = Constants.Constants.StringSymbolMap[currentCharacter];
            }
            else if (IoManager.IsEndOfFile)
            {
                CurrentToken.Symbol = Constants.Constants.StringSymbolMap[currentCharacter];
            }
            else
            {
                var nextCharacter = IoManager.GetNextCharacter().ToString();
                var symbol        = currentCharacter + nextCharacter;

                if (Constants.Constants.StringSymbolMap.ContainsKey(symbol))
                {
                    CurrentToken.Symbol = Constants.Constants.StringSymbolMap[symbol];
                }
                else
                {
                    _storedCharacters.Enqueue(nextCharacter);
                    _storedToken        = GetTokenWithCurrentPosition();
                    CurrentToken.Symbol = Constants.Constants.StringSymbolMap[currentCharacter];
                }
            }
        }
Exemplo n.º 5
0
        private string ScanSymbol(string currentCharacter, Func <char, bool> appendPredicate)
        {
            var symbolBuilder = new StringBuilder();

            symbolBuilder.Append(currentCharacter);

            CurrentToken = GetTokenWithCurrentPosition();

            var nextCharacter = ' ';

            while (!IoManager.IsEndOfFile)
            {
                nextCharacter = IoManager.GetNextCharacter();

                if (appendPredicate(nextCharacter))
                {
                    symbolBuilder.Append(nextCharacter);
                }
                else
                {
                    break;
                }
            }

            if (nextCharacter != ' ' && !appendPredicate(nextCharacter))
            {
                _storedCharacters.Enqueue(nextCharacter.ToString());
                _storedToken = GetTokenWithCurrentPosition();
            }

            return(symbolBuilder.ToString());
        }
Exemplo n.º 6
0
        private Type AnalyzeRecordVariable(Variable variable)
        {
            var type = new Type();

            AcceptTerminal(Symbol.Identifier);
            var record = SearchVariable(AcceptedToken.TextValue);

            AcceptTerminal(Symbol.Point);
            AcceptTerminal(Symbol.Identifier);
            if (AcceptedToken != null)
            {
                var field = record.Type.Record.Fields.FirstOrDefault(f => f.Identifier == AcceptedToken.TextValue);
                if (field == null)
                {
                    IoManager.InsertError(AcceptedToken.CharacterNumber, 152);
                }
                else
                {
                    switch (field.Type.BaseType)
                    {
                    case BaseType.Scalar:
                        type.BaseType   = BaseType.Scalar;
                        type.ScalarType = field.Type.ScalarType;
                        break;

                    case BaseType.Record:
                        StepBack();
                        type = AnalyzeRecordVariable(field);
                        break;
                    }
                }
            }

            return(type);
        }
Exemplo n.º 7
0
        private ScalarType AnalyzeExpression(HashSet <Symbol> followers)
        {
            var resultType = ScalarType.Unknown;

            if (!Belongs(Starters.Expression))
            {
                InsertError(1004);
                SkipTo(Starters.Expression, followers);
            }

            if (!Belongs(Starters.Expression))
            {
                return(resultType);
            }

            switch (CurrentSymbol)
            {
            case Symbol.Plus:
            case Symbol.Minus:
            case Symbol.Identifier:
            case Symbol.IntegerConstant:
            case Symbol.FloatConstant:
            case Symbol.CharConstant:
            case Symbol.StringConstant:
            case Symbol.True:
            case Symbol.False:
            case Symbol.LeftRoundBracket:
            case Symbol.Not:
                resultType = AnalyzeSimpleExpression(Union(RelationalOperators, followers));
                break;

            default:
                IoManager.InsertError(CurrentToken.CharacterNumber, 1004);
                break;
            }

            if (RelationalOperators.Contains(CurrentSymbol))
            {
                var operation  = AnalyzeRelationalOperators(Followers.RelationalOperators);
                var secondType = AnalyzeSimpleExpression(Union(Followers.SimpleExpression, followers));
                if (resultType != ScalarType.Boolean || secondType != ScalarType.Boolean)
                {
                    InsertError(144);
                    resultType = ScalarType.Unknown;
                }
                else
                {
                    resultType = ScalarType.Boolean;
                }
            }

            if (!Belongs(followers))
            {
                InsertError(1010);
                SkipTo(followers);
            }

            return(resultType);
        }
Exemplo n.º 8
0
 public void Select(Entity entity)
 {
     if (entity != null && entity.ID != PLAYER_ID)
     {
         entity.DamageBar.Level = 1f - (float)entity.Health / (float)entity.MaxHealth;
         IoManager.AddWidget(entity.OutIcon, TARGET_ICON_ID);
     }
 }
Exemplo n.º 9
0
 protected Command(string input, string[] data, Tester judge, StudentRepository repository, IoManager inputOutputManager)
 {
     this.Input              = input;
     this.Data               = data;
     this.judge              = judge;
     this.repository         = repository;
     this.inputOutputManager = inputOutputManager;
 }
Exemplo n.º 10
0
 public GameboyPlayScreen(string fname, RemuxWindow wnd)
 {
     romFile            = fname;
     vm                 = new GameBoy(new EmulatedCartridge(File.ReadAllBytes(fname)));
     vm.Gpu.VideoOutput = this;
     vm.Cpu.Run();
     this.wnd = wnd;
     ioman    = new IoManager(vm);
 }
Exemplo n.º 11
0
        public Token GetNextToken()
        {
            if (IsEndOfTokens)
            {
                return(null);
            }

            var currentCharacter = GetCurrentCharacter();

            if (string.IsNullOrWhiteSpace(currentCharacter))
            {
                return(GetNextToken());
            }

            if (currentCharacter == "'")
            {
                var isSuccess = ScanStringOrCharConstant();
                if (!isSuccess)
                {
                    return(GetNextToken());
                }
            }
            else if (char.IsDigit(currentCharacter, 0))
            {
                ScanNumericConstant(currentCharacter);
            }
            else if (char.IsLetter(currentCharacter, 0))
            {
                ScanKeywordOrIdentifier(currentCharacter);
            }
            else if (Constants.Constants.TypographicalSymbols.Contains(currentCharacter))
            {
                ScanTypographicalSymbol(currentCharacter);

                switch (CurrentToken.Symbol)
                {
                case Constants.Constants.Symbol.Comment:
                    SkipDoubleSlashComment();
                    return(GetNextToken());

                case Constants.Constants.Symbol.LeftComment:
                    SkipAsteriskParenthesisComment();
                    return(GetNextToken());

                case Constants.Constants.Symbol.LeftCurlyBracket:
                    SkipCurlyBracketComment();
                    return(GetNextToken());
                }
            }
            else
            {
                IoManager.InsertError(IoManager.CurrentCharacterNumber, 6);
                return(GetNextToken());
            }

            return(CurrentToken);
        }
Exemplo n.º 12
0
        public void InitializeUserInterface()
        {
            var targetPortrait = new Icon("", new IntRect(0, 0, 0, 0));

            IoManager.AddWidget(targetPortrait, TARGET_ICON_ID);
            var y      = UI_VERTICAL_START;
            var player = GetPlayer();

            player.OutIcon.ScaleX = UI_SCALE;
            player.OutIcon.ScaleY = UI_SCALE;
            player.Border         = new SolidBorder(UNSELECTED_SKILL_COLOR, 2f);
            player.OutIcon.AddDecorator(player.Border);
            player.DamageBar            = new DamageBarDecorator(DAMAGE_BAR_COLOR);
            player.DamageBar.InvertAxis = true;
            player.OutIcon.AddDecorator(player.DamageBar);
            player.OutIcon.Position = new Vector2f(UI_VERTICAL_START, y);
            IoManager.AddWidget(player.OutIcon);
            int i = 1;

            foreach (var s in player.skills)
            {
                if (s.Show)
                {
                    y               += UI_VERTICAL_SPACE;
                    s.OutIcon        = new ButtonIcon(s.IconTexture, s.IconRect);
                    s.OutIcon.ScaleX = UI_SCALE;
                    s.OutIcon.ScaleY = UI_SCALE;
                    s.Border         = new SolidBorder(UNSELECTED_SKILL_COLOR, 2f);
                    s.OutIcon.AddDecorator(s.Border);
                    s.DamageBar            = new DamageBarDecorator(COOLDOWN_BAR_COLOR);
                    s.DamageBar.InvertAxis = true;
                    s.OutIcon.AddDecorator(s.DamageBar);
                    s.OutIcon.Position     = new Vector2f(UI_VERTICAL_START, y);
                    s.OutIcon.MousePressed = (() => Simulator.Instance.SelectedSkill = i);
                    IoManager.AddWidget(s.OutIcon);
                    i++;
                }
            }
            foreach (var s in player.skills)
            {
                if (s.Show)
                {
                    s.Border.Color = SELECTED_SKILL_COLOR;
                    break;
                }
            }
            //this.waitIcon = new Icon ("00_base_pc_fx.png", new IntRect (568, 16, 8, 8));
            this.waitIcon          = new Icon("00_base_pc_fx.png", new IntRect(592, 24, 16, 16));
            this.waitIcon.ScaleX   = 2f;
            this.waitIcon.ScaleY   = 2f;
            this.waitIcon.Position = new Vector2f(IoManager.Width / 2 + 12, IoManager.Height / 2 - 64);
            this.waitIcon.Alpha    = 0;
            IoManager.AddWidget(this.waitIcon);
            IoManager.Pack();
            IoManager.RegisterToMouse(world.worldView);
        }
Exemplo n.º 13
0
        override public void OnDeath()
        {
            Simulator.Instance.IsGameOver = true;

            var position = new Vector2f(IoManager.Width / 2, IoManager.Height / 2 - 100);

            Logger.Info("UserAI", "OnDeath", "PLAYER is Dead");
            var label = new Label("YOU HAVE FALLEN", 48);

            label.AlignCenter = true;
            label.Color       = SFML.Graphics.Color.Red;
            label.Position    = position;
            IoManager.AddWidget(label);

            label             = new Label("Press SPACE to restart", 48);
            label.AlignCenter = true;
            label.Color       = SFML.Graphics.Color.White;
            position.Y       += 50;
            label.Position    = position;
            IoManager.AddWidget(label);

            label             = new Label("Thank you for playing this Alpha release", 32);
            label.AlignCenter = true;
            label.Color       = SFML.Graphics.Color.White;
            position.Y       += 160;
            label.Position    = position;
            IoManager.AddWidget(label);

            label             = new Label("An entire world will be developed in the next versions!", 32);
            label.AlignCenter = true;
            label.Color       = SFML.Graphics.Color.White;
            position.Y       += 80;
            label.Position    = position;
            IoManager.AddWidget(label);

            label             = new Label("With new levels, bosses, hordes of enemies and new spells and combinations!", 32);
            label.AlignCenter = true;
            label.Color       = SFML.Graphics.Color.White;
            position.Y       += 40;
            label.Position    = position;
            IoManager.AddWidget(label);

            label             = new Label("But we would gladly accept your comments and critiques!", 32);
            label.AlignCenter = true;
            label.Color       = SFML.Graphics.Color.White;
            position.Y       += 40;
            label.Position    = position;
            IoManager.AddWidget(label);

            label             = new Label("Contact us on http://www.wizardsofunica.com!", 32);
            label.AlignCenter = true;
            label.Color       = SFML.Graphics.Color.White;
            position.Y       += 40;
            label.Position    = position;
            IoManager.AddWidget(label);
        }
Exemplo n.º 14
0
        public void CreateParticleAt(string pid, int gx, int gy)
        {
            var ps = GameFactory.LoadParticleFromTemplate(pid, (gx + 0.5f) * this.CellWidth, (gy + 0.5f) * this.CellHeight, this.world.worldView.ObjectsLayer);

            if (ps != null)
            {
                IoManager.AddWidget(ps);
                Logger.Debug("Simulator", "CreateParticle", ps.ToString());
            }
        }
Exemplo n.º 15
0
        public TitleState() : base()
        {
            IoManager.Clear();
            IoManager.AddWidget(new Icon("0startscreen01_big.jpg", new IntRect(0, 0, 1280, 720)));
            var label = new Label("Click to start", 32, "munro.ttf");

            label.AlignCenter = true;
            label.Position    = new SFML.Window.Vector2f(IoManager.Width / 2, IoManager.Height - 64);
            IoManager.AddWidget(label);
        }
Exemplo n.º 16
0
        private static List <T> GetAllItems <T, TMap>(string[] fileTrackers, string file) where T : class where TMap : ClassMap
        {
            var result = new List <T>();

            foreach (var fileTracker in fileTrackers)
            {
                result.AddRange(IoManager.ReadWithMapper <T, TMap>(file.Replace(".csv", $".{fileTracker}.csv")));
            }
            return(result);
        }
Exemplo n.º 17
0
        private void SkipDoubleSlashComment()
        {
            _storedCharacters.Clear();
            var nextCharacter = ' ';

            while (!IoManager.IsEndOfFile && nextCharacter != '\n')
            {
                nextCharacter = IoManager.GetNextCharacter();
            }
        }
Exemplo n.º 18
0
        private static void Main()
        {
            IContentComparer  tester             = new Tester();
            IDirectoryManager ioManager          = new IoManager();
            IDatabase         repo               = new StudentsRepository(new RepositorySorter(), new RepositoryFilter());
            IInterpreter      currentInterpreter = new CommandInterpreter(tester, repo, ioManager);
            IReader           reader             = new InputReader(currentInterpreter);

            reader.StartReadingCommands();
        }
Exemplo n.º 19
0
 private void IoClose()
 {
     Disposer.Dispose(iom);
     iom = new NopManager();
     uir.Run(() =>
     {
         buffer.Flush();
         EnableControls(true);
     });
 }
Exemplo n.º 20
0
        public static void Main(string[] args)
        {
            try {
                Logger.Initialize(LogLevel.ALL, true);
                Logger.SetOutFile();

                Logger.Blacklist("AddLayer");
                Logger.Blacklist("AddRule");
                Logger.Blacklist("AreaAI");
                Logger.Blacklist("BackgroundMusic");
                Logger.Blacklist("CalculateLoS");
                Logger.Blacklist("CanShift");
                Logger.Blacklist("Effect");
                Logger.Blacklist("Entity");
                Logger.Blacklist("EventManager");
                Logger.Blacklist("GameFactory");
                Logger.Blacklist("IoManager");
                Logger.Blacklist("LavaAI");
                Logger.Blacklist("LoadTilemask");
                Logger.Blacklist("LoadWorldView");
                Logger.Blacklist("Main");
                Logger.Blacklist("MeleeAI");
                Logger.Blacklist("OnRound");
                Logger.Blacklist("OutObject");
                Logger.Blacklist("Run");
                Logger.Blacklist("SetDungeon");
                Logger.Blacklist("SetUserEvent");
                Logger.Blacklist("Skill");
                //Logger.Blacklist ("Simulator");
                Logger.Blacklist("TestLevel");
                Logger.Blacklist("TranslateAnimation");
                Logger.Blacklist("WorldFactory");
                Logger.Blacklist("XmlUtilities");

                IoManager.Initialize("Wizards of Unica", 1280, 720);
            }
            catch (Exception ex) {
                Console.WriteLine("Configuration Error, Aborting: " + ex.ToString());
                return;
            }

            GameState state = new TitleState();

            while (true)
            {
                var inputs = IoManager.GetInputs();
                if (inputs.Command == InputCommands.QUIT)
                {
                    return;
                }
                state.Logic(inputs);
                GameState.ChangeState(ref state);
                state.Render();
            }
        }
        public static void Main()
        {
            var tester     = new Tester();
            var ioManager  = new IoManager();
            var repository = new StudentsRepository(new RepositoryFilter(), new RepositorySorter());

            var currentInterpreter = new CommandInterpreter(tester, repository, ioManager);
            var reader             = new InputReader(currentInterpreter);

            reader.StartReadingCommands();
        }
Exemplo n.º 22
0
        public void CreateParticleOn(string pid, Entity target)
        {
            var flip = (target.OutObject.Facing == Facing.RIGHT) ? false : true;
            var ps   = GameFactory.LoadParticleFromTemplate(pid, 0f, 0f, this.world.worldView.ObjectsLayer, flip);

            if (ps != null)
            {
                target.OutObject.AddParticleSystem(ps);
                IoManager.AddWidget(ps);
            }
        }
Exemplo n.º 23
0
        private void ButtonOpenSerial_Click(object sender, EventArgs e)
        {
            var name = comboBoxSerial.Text;

            EnableControls(false);
            ior.Run(() =>
            {
                iom = new SerialManager(name, serial);
                uir.Run(() => buffer.Log("success", "Serial {0} open", iom.Name));
            });
        }
Exemplo n.º 24
0
        private void ScanNumericConstant(string currentCharacter)
        {
            var gotDot        = false;
            var isExponential = false;
            var lastChar      = currentCharacter[0];
            var symbol        = ScanSymbol(currentCharacter, c =>
            {
                var result =
                    char.IsDigit(c) && (lastChar != 'E' || lastChar != 'e') ||
                    c == '.' && !gotDot && !isExponential ||
                    char.IsDigit(lastChar) && (c == 'E' || c == 'e') && !isExponential ||
                    isExponential && (c == '+' || c == '-');
                if (c == '.')
                {
                    gotDot = true;
                }
                if (c == 'E' || c == 'e')
                {
                    isExponential = true;
                }
                lastChar = c;
                return(result);
            });

            var isParsed = double.TryParse(symbol, NumberStyles.Float,
                                           NumberFormatInfo.InvariantInfo, out var numericConstantValue);

            if (!isParsed)
            {
                IoManager.InsertError(CurrentToken.CharacterNumber, 50);
            }

            CurrentToken.NumericValue = numericConstantValue;

            CurrentToken.Symbol =
                gotDot || isExponential
                    ? Constants.Constants.Symbol.FloatConstant
                    : Constants.Constants.Symbol.IntegerConstant;

            if (CurrentToken.Symbol == Constants.Constants.Symbol.IntegerConstant && CurrentToken.NumericValue > Constants.Constants.MaximumIntegerValue)
            {
                IoManager.InsertError(CurrentToken.CharacterNumber, 203);
            }

            if (CurrentToken.Symbol == Constants.Constants.Symbol.FloatConstant && CurrentToken.NumericValue * Constants.Constants.MaximumFloatValue < 1)
            {
                IoManager.InsertError(CurrentToken.CharacterNumber, 206);
            }

            if (CurrentToken.Symbol == Constants.Constants.Symbol.FloatConstant && CurrentToken.NumericValue > Constants.Constants.MaximumFloatValue)
            {
                IoManager.InsertError(CurrentToken.CharacterNumber, 207);
            }
        }
Exemplo n.º 25
0
        /// <summary>
        /// Tries to apply the skill to the target.
        /// </summary>
        /// <returns><c>true</c>, if skill was applied, <c>false</c> otherwise.</returns>
        /// <param name="skill">Skill.</param>
        /// <param name="actor">Actor.</param>
        /// <param name="target">Target, if null the target will be actor</param>
        /// <param name="gx">Grid x, if < 0 the target will be target</param>
        /// <param name="gy">Grid y, if < 0 the target will be target</param>
        public bool TrySkill(Skill skill, Entity actor, Entity target = null, int gx = -1, int gy = -1)
        {
            var res = false;

            if (skill.RoundsToGo < 1)
            {
                if (gx >= 0 && gy >= 0)
                {
                    res = skill.OnEmpty(actor, gx, gy);
                }
                else if (target != null)
                {
                    Logger.Debug("Simulator", "TrySkill", "Trying skill " + skill.Name + " on " + target.ID);
                    res = skill.OnTarget(actor, target);
                    target.DamageBar.Level = 1f - (float)target.Health / (float)target.MaxHealth;
                    if (target.ID != PLAYER_ID)
                    {
                        IoManager.AddWidget(target.OutIcon, TARGET_ICON_ID);
                    }
                }
                else
                {
                    res = skill.OnSelf(actor);
                }
            }
            if (res == true)
            {
                //skill.RoundsToGo = skill.CurrentCoolDown;
                if (skill.Combo != null)
                {
                    foreach (var s in actor.skills)
                    {
                        if (skill.Combo.Contains(s.ID))
                        {
                            s.RoundsToGo      = s.CurrentCoolDown;                        // XXX "skill" to inherith cooldown
                            s.CurrentCoolDown = skill.CurrentCoolDown;
                            if (s.DamageBar != null)
                            {
                                s.DamageBar.Level = (float)s.RoundsToGo / (float)s.CurrentCoolDown;
                            }
                        }
                    }
                }

                /*else {
                 *      skill.CurrentCoolDown = skill.CoolDown;
                 *      skill.RoundsToGo = skill.CoolDown;
                 *      if (skill.DamageBar != null) {
                 *              skill.DamageBar.Level = (float)skill.RoundsToGo / (float)skill.CurrentCoolDown;
                 *      }
                 * }*/
            }
            return(res);
        }
Exemplo n.º 26
0
        private void ButtonOpenSocket_Click(object sender, EventArgs e)
        {
            var host = textBoxClientHost.Text;
            var port = (int)numericUpDownClientPort.Value;

            EnableControls(false);
            ior.Run(() =>
            {
                iom = new SocketManager(host, port);
                uir.Run(() => buffer.Log("success", "Socket {0} open", iom.Name));
            });
        }
Exemplo n.º 27
0
        private void ButtonListenSocket_Click(object sender, EventArgs e)
        {
            var ip   = comboBoxServerIP.Text;
            var port = (int)numericUpDownServerPort.Value;

            EnableControls(false);
            ior.Run(() =>
            {
                iom = new ListenManager(ip, port, ior);
                uir.Run(() => buffer.Log("success", "Listener {0} open", iom.Name));
            });
        }
Exemplo n.º 28
0
        /// <summary>
        /// Entry point of program.
        /// </summary>
        /// <param studentByName="args">Arguments.</param>
        public static void Main(string[] args)
        {
            IContentComparer  tester             = new Tester();
            IDirectoryManager manager            = new IoManager();
            IDatabase         studentsRepository = new StudentsRepository(new RepositoryFilter(), new RepositorySorter());

            ICommandInterpreter currentInterpreter =
                new CommandInterpreter(tester, studentsRepository, manager);

            var reader = new InputReader(currentInterpreter);

            reader.StartReadingCommands();
        }
Exemplo n.º 29
0
        private void AnalyzeType(HashSet <Symbol> followers)
        {
            _currentType = new Type();

            if (!Belongs(Starters.Type))
            {
                InsertError(331);
                SkipTo(Starters.Type, followers);
            }

            if (!Belongs(Starters.Type))
            {
                return;
            }

            switch (CurrentSymbol)
            {
            case Symbol.Identifier:
            case Symbol.LeftRoundBracket:
            case Symbol.Plus:
            case Symbol.Minus:
            case Symbol.IntegerConstant:
            case Symbol.FloatConstant:
            case Symbol.CharConstant:
            case Symbol.StringConstant:
                AnalyzeSimpleType(Union(Followers.SimpleType, followers));
                break;

            case Symbol.Record:
            case Symbol.Array:
            case Symbol.Set:
            case Symbol.File:
            case Symbol.Packed:
                AnalyzeComplexType(Union(Followers.ComplexType, followers));
                break;

            case Symbol.Caret:
                AnalyzeReferenceType(followers);
                break;

            default:
                IoManager.InsertError(CurrentToken.CharacterNumber, 331);
                break;
            }

            if (!Belongs(followers))
            {
                InsertError(10);
                SkipTo(followers);
            }
        }
Exemplo n.º 30
0
        public void Kill(Entity target, int delayMillis = 0)
        {
            Logger.Debug("Simulator", "Kill", "Trying to kill " + target.ID);
            target.Kill();
            if (target.Visible == true)
            {
                if (target.DeathAnimation == String.Empty)
                {
                    //CreateParticleAt (SPAWN_PARTICLE, target.X, target.Y);
                    var ps = new ParticleSystem("DEATH");
                    ps.TTL      = 2000;
                    ps.Layer    = this.world.worldView.ObjectsLayer;
                    ps.Position = new Vector2f(target.X * this.CellWidth + target.DeathRect.Left, target.Y * this.CellHeight + target.DeathRect.Top);

                    var emitter = new Emitter(ps, 0);
                    //emitter.Offset = new Vector2f (target.DeathRect.Top, target.DeathRect.Left);
                    emitter.ParticleTTL    = 800;
                    emitter.SpawnCount     = 64;
                    emitter.SpawnDeltaTime = 50;
                    emitter.StartDelay     = 250;
                    emitter.TTL            = 90;
                    emitter.AddParticleTemplate("00_base_pc_fx.png", 576, 0, 1, 1, 2);
                    emitter.AddParticleTemplate("00_base_pc_fx.png", 576, 0, 1, 1, 2);
                    emitter.AddParticleTemplate("00_base_pc_fx.png", 576, 0, 1, 1, 4);
                    emitter.AddAnimator(new GravityAnimation(new Vector2f(0f, 0.0002f)));
                    emitter.AddAnimator(new FadeAnimation(0, 0, 800));
                    emitter.AddVariator(new GridSpawner(target.DeathRect.Width, target.DeathRect.Height, 4, 4));
                    emitter.AddVariator(new BurstSpawner(0.05f));
                    var cps = new ColorPickerSpawner();
                    cps.AddColor(target.DeathMain);
                    cps.AddColor(target.DeathMain);
                    cps.AddColor(target.DeathSecundary);
                    emitter.AddVariator(cps);
                    ps.AddEmitter(emitter);

                    //var ps = GameFactory.LoadParticleFromTemplate (pid, target.X * this.CellWidth, target.Y * this.CellHeight, this.world.worldView.ObjectsLayer);
                    IoManager.AddWidget(ps);
                    target.OutObject.AddAnimator(new FadeAnimation(0, delayMillis, 500));
                }
                else
                {
                    SetAnimation(target, target.DeathAnimation);
                }
                this.events.WaitAndRun(delayMillis /* + 500*/, new DestroyEvent(target.ID));
            }
            else
            {
                this.DestroyObject(target.ID);
            }
        }