Esempio n. 1
0
        private static int UpdatePlayerEntity(ParserState state, string rawEntity, Tag tag, int entity)
        {
            int tmp;
            if(!int.TryParse(rawEntity, out tmp) && !rawEntity.StartsWith("[") && rawEntity != "GameEntity")
            {
                if(entity != tag.Value)
                {
                    entity = tag.Value;
                    var tmpName = ((PlayerEntity)state.CurrentGame.Data[1]).Name;
                    ((PlayerEntity)state.CurrentGame.Data[1]).Name =
                        ((PlayerEntity)state.CurrentGame.Data[2]).Name;
                    ((PlayerEntity)state.CurrentGame.Data[2]).Name = tmpName;
                    foreach(var dataObj in ((Game)state.Node.Object).Data)
                    {
                        var tChange = dataObj as TagChange;
                        if(tChange != null)
                            tChange.Entity = tChange.Entity == 2 ? 3 : 2;
                    }
                }
            }

            return entity;
        }
Esempio n. 2
0
 private static void UpdateCurrentPlayer(ParserState state, string rawEntity, Tag tag)
 {
     if(tag.Value == 0)
     {
         try
         {
             Helper.ParseEntity(rawEntity, state);
         }
         catch(Exception ex)
         {
             var currentPlayer =
                 (PlayerEntity)state.CurrentGame.Data.Single(x => (x is PlayerEntity) && ((PlayerEntity)x).Id == state.CurrentPlayerId);
             currentPlayer.Name = rawEntity;
         }
     }
     else if(tag.Value == 1)
     {
         try
         {
             Helper.ParseEntity(rawEntity, state);
         }
         catch(Exception ex)
         {
             var currentPlayer =
                 (PlayerEntity)state.CurrentGame.Data.Single(x => (x is PlayerEntity) && ((PlayerEntity)x).Id != state.CurrentPlayerId);
             currentPlayer.Name = rawEntity;
         }
         state.CurrentPlayerId = Helper.ParseEntity(rawEntity, state);
     }
 }