public ServiceResult GetProfileScreens()
        {
            List <DataScreen> screens = new List <DataScreen>();
            var screen = new DataScreen();

            //screen.Command = 'SEARCHBY';
            //screen.Field = 'CATEGORY';
            //screen.Selected = false;
            //screen.Caption = name;
            //screen.Value = name; // 'false';
            //screen.Type = 'category';
            screens.Add(screen);
            return(ServiceResponse.OK("", screens));
        }
Beispiel #2
0
        protected DataQuery BuildQuery(string typeName, List <DataScreen> screens)
        {
            DataQuery dq = new DataQuery();

            string table = new TreeMonDbContext(this._connectionKey).GetTableName(typeName);

            if (string.IsNullOrEmpty(table))
            {
                dq.SQL = "ERROR: Table name could not be found.";
                return(dq);
            }

            //Set default sql query
            dq.SQL        = "SELECT * FROM " + table;
            dq.Parameters = null;

            if (screens == null || screens.Count() == 0)
            {
                return(dq);
            }

            //Check if we do a distinct query.
            //
            DataScreen distinctDataScreen = screens.FirstOrDefault(w => w.Command?.ToLower() == "distinct");

            if (distinctDataScreen == null)
            {
                dq.SQL += GetWhereClause(screens);
            }
            else
            {
                dq.SQL = "SELECT DISTINCT( " + distinctDataScreen.Field + " ) FROM " + table + GetWhereClause(screens);
            }


            return(dq);
        }
        public void DatasetManager_GetData_Measurements_DataScreens()
        {
            //the getfilters function gets distinct values from a table field that will
            //used to build the query to get the dataset. Controler only pulling from fireincidents for now. need to make it dynamic.
            List <DataScreen> filters = new List <DataScreen>();
            DataScreen        qf      = new DataScreen();

            qf.Field    = "UnitOfMeasure";
            qf.Operator = "=";
            qf.Value    = "centimeters";
            qf.Type     = "sql"; //tell the parser is a sql query
            qf.Junction = "AND"; //since more filters are to follow add a conjunction.
            filters.Add(qf);

            qf          = new DataScreen();
            qf.Field    = "Measure";
            qf.Operator = "BETWEEN";
            qf.Type     = "sql"; //tell the parser is a sql query
            qf.Value    = "20";
            qf.Order    = 0;     //this is the first part of the between statement
            qf.Junction = "AND";
            filters.Add(qf);

            qf          = new DataScreen();
            qf.Field    = "Measure";
            qf.Operator = "BETWEEN";
            qf.Type     = "sql"; //tell the parser is a sql query
            qf.Value    = "50";
            qf.Order    = 1;     //second part of the between statement
            filters.Add(qf);

            DatasetManager   dm     = new DatasetManager(connectionKey, "TESTSESSION");
            List <DataPoint> series = dm.GetData("MeasurementLog", "Measure", null);

            Assert.IsTrue(series.Count > 0);
        }
Beispiel #4
0
        public override void Update(GameTime gameTime)
        {
            EllapsedTime += gameTime.ElapsedGameTime.TotalSeconds;

            if (EllapsedTime >= 10)
            {
                int OldNumberOfGameScreen  = ListGameScreen.Count;
                MultiplayerScreen Autoplay = new MultiplayerScreen();
                Autoplay.Load();
                Constants.ShowAnimation = false;
                DeathmatchMap NewMap = Autoplay.LoadAutoplay();
                NewMap.ListGameScreen = ListGameScreen;
                NewMap.Load();
                NewMap.Init();
                NewMap.TogglePreview(true);

                //Remove any GameScreen created by the map so they don't show up immediately.
                List <GameScreen> ListGameScreenCreatedByMap = new List <GameScreen>(ListGameScreen.Count - OldNumberOfGameScreen);
                for (int S = ListGameScreen.Count - 1 - OldNumberOfGameScreen; S >= 0; --S)
                {
                    ListGameScreenCreatedByMap.Add(ListGameScreen[S]);
                    ListGameScreen.RemoveAt(S);
                }

                RemoveAllScreens();
                ListGameScreen.Insert(0, NewMap);
                NewMap.Update(gameTime);

                for (int S = 0; S < ListGameScreenCreatedByMap.Count; ++S)
                {
                    ListGameScreen.Insert(0, ListGameScreenCreatedByMap[S]);
                    ListGameScreenCreatedByMap[S].Update(gameTime);
                }

                ListGameScreenCreatedByMap.Clear();
            }

            if (InputHelper.InputUpPressed())
            {
                EllapsedTime = 0;

                SelectedChoice--;
                sndSelection.Play();

                if (SelectedChoice == -1)
                {
                    SelectedChoice = 4;
                }
            }
            else if (InputHelper.InputDownPressed())
            {
                EllapsedTime = 0;

                SelectedChoice++;
                sndSelection.Play();

                if (SelectedChoice == 5)
                {
                    SelectedChoice = 0;
                }
            }
            else if (InputHelper.InputConfirmPressed())
            {
                switch ((MenuChoices)SelectedChoice)
                {
                case MenuChoices.NewGame:
                    sndIntroSong.Stop();
                    sndConfirm.Play();

                    /*
                     *
                     * int OldNumberOfGameScreen = ListGameScreen.Count;
                     * StreamReader BR = new StreamReader("Content/Map path.ini");
                     * DeathmatchMap NewMap = new DeathmatchMap(BR.ReadLine(), 0, new Dictionary<string, List<Core.Units.Squad>>());
                     * BR.Close();
                     * NewMap.ListGameScreen = ListGameScreen;
                     * NewMap.PlayerRoster = new Roster();
                     * NewMap.PlayerRoster.LoadRoster();
                     * NewMap.Load();
                     * NewMap.Init();
                     * NewMap.TogglePreview(true);
                     *
                     * //Remove any GameScreen created by the map so they don't show up immediately.
                     * List<GameScreen> ListGameScreenCreatedByMap = new List<GameScreen>(ListGameScreen.Count - OldNumberOfGameScreen);
                     * for (int S = ListGameScreen.Count - 1 - OldNumberOfGameScreen; S >= 0; --S)
                     * {
                     *  ListGameScreenCreatedByMap.Add(ListGameScreen[S]);
                     *  ListGameScreen.RemoveAt(S);
                     * }
                     *
                     * RemoveAllScreens();
                     * ListGameScreen.Insert(0, NewMap);
                     * NewMap.Update(gameTime);
                     *
                     * for (int S = 0; S < ListGameScreenCreatedByMap.Count; ++S)
                     * {
                     *  ListGameScreen.Insert(0, ListGameScreenCreatedByMap[S]);
                     *  ListGameScreenCreatedByMap[S].Update(gameTime);
                     * }
                     *
                     * ListGameScreenCreatedByMap.Clear();*/
                    PushScreen(new GameSelection());
                    break;

                case MenuChoices.QuickLoad:
                    if (File.Exists("User Data/Saves/TempSave.sav"))
                    {
                        sndIntroSong.Stop();
                        sndConfirm.Play();
                        BattleMap QuickLoadMap = BattleMap.LoadTemporaryMap(ListGameScreen);
                        QuickLoadMap.TogglePreview(true);
                        ListGameScreen.Insert(0, QuickLoadMap);
                    }
                    else
                    {
                        sndDeny.Play();
                    }
                    break;

                case MenuChoices.Encyclopedia:
                    sndDeny.Play();
                    break;

                case MenuChoices.Option:
                    PushScreen(new OptionMenu());
                    sndConfirm.Play();
                    break;

                case MenuChoices.LoadGame:
                    if (File.Exists("User Data/Saves/SRWE Save.bin"))
                    {
                        sndIntroSong.Stop();
                        sndConfirm.Play();

                        Roster PlayerRoster = new Roster();
                        PlayerRoster.LoadRoster();
                        Dictionary <string, Unit> DicUnitType = Unit.LoadAllUnits();
                        Dictionary <string, BaseSkillRequirement>     DicRequirement          = BaseSkillRequirement.LoadAllRequirements();
                        Dictionary <string, BaseEffect>               DicEffect               = BaseEffect.LoadAllEffects();
                        Dictionary <string, AutomaticSkillTargetType> DicAutomaticSkillTarget = AutomaticSkillTargetType.LoadAllTargetTypes();
                        Dictionary <string, ManualSkillTarget>        DicManualSkillTarget    = ManualSkillTarget.LoadAllTargetTypes();
                        DataScreen.LoadProgression(PlayerRoster, DicUnitType, DicRequirement, DicEffect, DicAutomaticSkillTarget, DicManualSkillTarget);
                        PushScreen(new NewIntermissionScreen(PlayerRoster));
                    }
                    else
                    {
                        sndDeny.Play();
                    }
                    break;
                }
            }
        }
Beispiel #5
0
        //public static List<dynamic> FilterQueryable(IQueryable<dynamic> input, string screens)
        //{
        //    Debug.Assert(false, "NOT IMPLEMENTED. yet");
        //    //input = input.Where(w => w?.UUID != screen.Value).ToList();
        //    return new List<dynamic>();
        //}

        public static List <dynamic> DistinctBy(List <dynamic> input, DataScreen screen)
        {
            if (input == null || input.Count == 0)
            {
                return(input);
            }
            switch (screen.Field?.ToUpper())
            {
            //Node Properties
            case "UUID":
                input = input.DistinctBy(d => d.UUID).ToList();
                break;

            case "UUIDTYPE":
                input = input.DistinctBy(d => d.UUIDType).ToList();
                break;

            case "UUPARENTID":
                input = input.DistinctBy(d => d.UUParentID).ToList();
                break;

            case "UUPARENTIDTYPE":
                input = input.DistinctBy(d => d.UUParentIDType).ToList();
                break;

            case "NAME":
                input = input.DistinctBy(d => d.Name).ToList();
                break;

            case "STATUS":
                input = input.DistinctBy(d => d.Status).ToList();
                break;

            case "ACCOUNTUUID":
                input = input.DistinctBy(d => d.AccountUUID).ToList();
                break;

            case "ACTIVE":
                input = input.DistinctBy(d => d.Active).ToList();
                break;

            case "DELETED":
                input = input.DistinctBy(d => d.Deleted).ToList();
                break;

            case "PRIVATE":
                input = input.DistinctBy(d => d.Private).ToList();
                break;

            case "SORTORDER":
                input = input.DistinctBy(d => d.SortOrder).ToList();
                break;

            case "CREATEDBY":
                input = input.DistinctBy(d => d.CreatedBy).ToList();
                break;

            case "DATECREATED":
                input = input.Where(w => Convert.ToDateTime(w?.DateCreated) == Convert.ToDateTime(screen.Value)).ToList();
                break;

            //Strain Specific
            case "HARVESTTIME":
                input = input.DistinctBy(d => d.HarvestTime).ToList();
                break;

            //Category Specific
            case "CATEGORYTYPE":
                input = input.DistinctBy(d => d.CategoryType).ToList();
                break;

            //Product Specific
            case "CATEGORY":
                input = input.DistinctBy(d => d.CategoryUUID).ToList();
                break;

            case "MANUFACTURER":
                input = input.DistinctBy(d => d.ManufacturerUUID).ToList();
                break;

            case "DEPARTMENT":
                input = input.DistinctBy(d => d.DepartmentUUID).ToList();
                break;

            //Vendor Specific
            case "BREEDER":
                input = input.DistinctBy(d => d.Breeder).ToList();
                break;

            case "GROWER":
                input = input.Where(w => w?.Grower).ToList();
                break;

            case "DISPENSARY":
                input = input.DistinctBy(d => d.Dispensary).ToList();
                break;

            case "BREEDERTYPE":
                input = input.DistinctBy(d => d.BreederType).ToList();
                break;

            //Units Of Measure
            case "CATEGORYUUID":
                #region original code not ported. may not be needed
                //CategoryManager categoryManager = new CategoryManager(Globals.DBConnectionKey, Request.Headers?.Authorization?.Parameter);
                //Category category = categoryManager.GetBy(f.SearchTerm);
                //if (category == null)
                //    continue;
                //input = input.Where(w => w.Category?.EqualsIgnoreCase(category.Name.ToUpper()).ToList();
                #endregion
                Debug.Assert(false, "Verify the search term is category and not uuid");
                input = input.DistinctBy(d => d.BreederType).ToList();
                break;
            }
            return(input);
        }
Beispiel #6
0
        public static List <dynamic> SearchBy(List <dynamic> input, DataScreen screen)
        {
            if (input == null || input.Count == 0 || string.IsNullOrWhiteSpace(screen.Value) || string.IsNullOrWhiteSpace(screen.Field) || string.IsNullOrWhiteSpace(screen.Command))
            {
                return(input);
            }
            try
            {
                switch (screen.Field?.ToUpper())
                {
                //Node Properties
                case "UUID":
                    if (screen.Command.EqualsIgnoreCase("CONTAINS"))
                    {
                        input = input.Where(w => w.UUID?.ToUpper().Contains(screen.Value)).ToList();
                    }
                    else if (screen.Command.EqualsIgnoreCase("SEARCH!BY"))
                    {
                        input = input.Where(w => w.UUID != screen.Value).ToList();
                    }
                    else
                    {
                        input = input.Where(w => w.UUID == screen.Value).ToList();
                    }
                    break;

                case "VARIETYUUID":
                    if (screen.Command.EqualsIgnoreCase("CONTAINS"))
                    {
                        input = input.Where(w => w.CategoryUUID?.ToUpper().Contains(screen.Value.ToUpper())).ToList();
                    }
                    else if (screen.Command.EqualsIgnoreCase("SEARCH!BY"))
                    {
                        input = input.Where(w => w.CategoryUUID != screen.Value).ToList();
                    }
                    else
                    {
                        input = input.Where(w => w.CategoryUUID?.ToUpper()?.Trim() == screen.Value?.ToUpper()?.Trim()).ToList();
                    }
                    break;

                case "UUIDTYPE":
                    if (screen.Command.EqualsIgnoreCase("CONTAINS"))
                    {
                        input = input.Where(w => w.UUIDType?.ToUpper().Contains(screen.Value.ToUpper())).ToList();
                    }
                    else if (screen.Command.EqualsIgnoreCase("SEARCH!BY"))
                    {
                        input = input.Where(w => w.UUIDType != screen.Value).ToList();
                    }
                    else
                    {
                        input = input.Where(w => w.UUIDType == screen.Value).ToList();
                    }
                    break;

                case "UUPARENTID":
                    if (screen.Command.EqualsIgnoreCase("CONTAINS"))
                    {
                        input = input.Where(w => w.UUParentID?.ToUpper().Contains(screen.Value.ToUpper())).ToList();
                    }
                    else if (screen.Command.EqualsIgnoreCase("SEARCH!BY"))
                    {
                        input = input.Where(w => w.UUParentID != screen.Value).ToList();
                    }
                    else
                    {
                        input = input.Where(w => w.UUParentID == screen.Value).ToList();
                    }
                    break;

                case "UUPARENTIDTYPE":
                    if (screen.Command.EqualsIgnoreCase("CONTAINS"))
                    {
                        input = input.Where(w => w.UUParentIDType?.ToUpper().Contains(screen.Value.ToUpper())).ToList();
                    }
                    else if (screen.Command.EqualsIgnoreCase("SEARCH!BY"))
                    {
                        input = input.Where(w => w.UUParentIDType != screen.Value).ToList();
                    }
                    else
                    {
                        input = input.Where(w => w.UUParentIDType == screen.Value).ToList();
                    }
                    break;

                case "NAME":
                    if (screen.Command.EqualsIgnoreCase("CONTAINS"))
                    {
                        input = input.Where(w => w.Name?.ToUpper()?.Contains(screen.Value.ToUpper().ToUpper())).ToList();
                    }
                    else if (screen.Command.EqualsIgnoreCase("SEARCH!BY"))
                    {
                        input = input.Where(w => w.Name?.IndexOf(screen.Value, StringComparison.OrdinalIgnoreCase) == -1).ToList();
                    }
                    else
                    {
                        input = input.Where(w => w.Name?.IndexOf(screen.Value, StringComparison.OrdinalIgnoreCase) != -1).ToList();
                    }
                    break;

                case "STATUS":
                    if (screen.Command.EqualsIgnoreCase("CONTAINS"))
                    {
                        input = input.Where(w => w.Status?.ToUpper().Contains(screen.Value.ToUpper())).ToList();
                    }
                    else if (screen.Command.EqualsIgnoreCase("SEARCH!BY"))
                    {
                        input = input.Where(w => w.Status?.IndexOf(screen.Value, StringComparison.OrdinalIgnoreCase) == -1).ToList();
                    }
                    else
                    {
                        input = input.Where(w => w.Status?.IndexOf(screen.Value, StringComparison.OrdinalIgnoreCase) != -1).ToList();
                    }
                    break;

                case "ACCOUNTUUID":
                    if (screen.Command.EqualsIgnoreCase("CONTAINS"))
                    {
                        input = input.Where(w => w.AccountUUID?.ToUpper().Contains(screen.Value.ToUpper())).ToList();
                    }
                    else if (screen.Command.EqualsIgnoreCase("SEARCH!BY"))
                    {
                        input = input.Where(w => w.AccountUUID != screen.Value).ToList();
                    }
                    else
                    {
                        input = input.Where(w => w.AccountUUID == screen.Value).ToList();
                    }
                    break;

                case "ACTIVE":

                    if (screen.Command.EqualsIgnoreCase("SEARCH!BY"))
                    {
                        input = input.Where(w => Convert.ToBoolean(w.Active) != Convert.ToBoolean(screen.Value)).ToList();
                    }
                    else
                    {
                        input = input.Where(w => Convert.ToBoolean(w.Active) == Convert.ToBoolean(screen.Value)).ToList();
                    }
                    break;

                case "BREEDER":
                    if (screen.Command.EqualsIgnoreCase("SEARCH!BY"))
                    {
                        input = input.Where(w => Convert.ToBoolean(w.Breeder) != Convert.ToBoolean(screen.Value)).ToList();
                    }
                    else
                    {
                        input = input.Where(w => Convert.ToBoolean(w.Breeder) == Convert.ToBoolean(screen.Value)).ToList();
                    }
                    break;

                case "DELETED":

                    if (screen.Command.EqualsIgnoreCase("SEARCH!BY"))
                    {
                        input = input.Where(w => Convert.ToBoolean(w.Deleted) != Convert.ToBoolean(screen.Value)).ToList();
                    }
                    else
                    {
                        input = input.Where(w => Convert.ToBoolean(w?.Deleted) == Convert.ToBoolean(screen.Value)).ToList();
                    }
                    break;

                case "PRIVATE":

                    if (screen.Command.EqualsIgnoreCase("SEARCH!BY"))
                    {
                        input = input.Where(w => Convert.ToBoolean(w.Private) != Convert.ToBoolean(screen.Value)).ToList();
                    }
                    else
                    {
                        input = input.Where(w => Convert.ToBoolean(w.Private) == Convert.ToBoolean(screen.Value)).ToList();
                    }
                    break;

                case "SORTORDER":

                    if (screen.Command.EqualsIgnoreCase("SEARCH!BY"))
                    {
                        input = input.Where(w => w.SortOrder != StringEx.ConvertTo <int>(screen.Value)).ToList();
                    }
                    else
                    {
                        input = input.Where(w => w.SortOrder == StringEx.ConvertTo <int>(screen.Value)).ToList();
                    }
                    break;

                case "CREATEDBY":
                    if (screen.Command.EqualsIgnoreCase("CONTAINS"))
                    {
                        input = input.Where(w => w.CreatedBy?.ToUpper().Contains(screen.Value.ToUpper())).ToList();
                    }
                    else if (screen.Command.EqualsIgnoreCase("SEARCH!BY"))
                    {
                        input = input.Where(w => w.CreatedBy != screen.Value).ToList();
                    }
                    else
                    {
                        input = input.Where(w => w.CreatedBy == screen.Value).ToList();
                    }
                    break;

                case "DATECREATED":
                    if (screen.Command.EqualsIgnoreCase("SEARCH!BY"))
                    {
                        input = input.Where(w => Convert.ToDateTime(w.DateCreated) != Convert.ToDateTime(screen.Value)).ToList();
                    }
                    else
                    {
                        input = input.Where(w => Convert.ToDateTime(w.DateCreated) == Convert.ToDateTime(screen.Value)).ToList();
                    }
                    break;

                //Strain Specific
                case "HARVESTTIME":
                    if (screen.Command.EqualsIgnoreCase("SEARCH!BY"))
                    {
                        input = input.Where(w => w.HarvestTime != screen.Value).ToList();
                    }
                    else
                    {
                        input = input.Where(w => w.HarvestTime == StringEx.ConvertTo <int>(screen.Value)).ToList();
                    }
                    break;

                //Category Specific
                case "CATEGORYTYPE":
                    if (screen.Command.EqualsIgnoreCase("CONTAINS"))
                    {
                        input = input.Where(w => w.CategoryType?.ToUpper().Contains(screen.Value.ToUpper())).ToList();
                    }
                    else if (screen.Command.EqualsIgnoreCase("SEARCH!BY"))
                    {
                        input = input.Where(w => w.CategoryType?.ToUpper() != screen.Value).ToList();
                    }
                    else
                    {
                        input = input.Where(w => StringEx.EqualsEx(w.CategoryType, screen.Value))?.ToList();
                    }
                    break;

                //Location and Finance Account
                case "LOCATIONTYPE":
                    if (screen.Command.EqualsIgnoreCase("CONTAINS"))
                    {
                        input = input.Where(w => w.LocationType?.ToUpper().Contains(screen.Value.ToUpper())).ToList();
                    }
                    else if (screen.Command.EqualsIgnoreCase("SEARCH!BY"))
                    {
                        input = input.Where(w => w.LocationType?.ToString()?.ToUpper() != screen.Value).ToList();
                    }
                    else
                    {
                        input = input.Where(w => StringEx.EqualsEx(w.LocationType, screen.Value)).ToList();
                    }
                    break;

                //Product Specific
                case "CATEGORY":
                    if (screen.Command.EqualsIgnoreCase("CONTAINS"))
                    {
                        input = input.Where(w => w.CategoryUUID?.ToUpper().Contains(screen.Value.ToUpper())).ToList();
                    }
                    else if (screen.Command.EqualsIgnoreCase("SEARCH!BY"))
                    {
                        input = input.Where(w => w.CategoryUUID != screen.Value).ToList();
                    }
                    else
                    {
                        input = input.Where(w => w.CategoryUUID == screen.Value).ToList();
                    }
                    break;

                case "MANUFACTURER":
                    if (screen.Command.EqualsIgnoreCase("CONTAINS"))
                    {
                        input = input.Where(w => w.ManufacturerUUID?.ToUpper().Contains(screen.Value.ToUpper())).ToList();
                    }
                    else if (screen.Command.EqualsIgnoreCase("SEARCH!BY"))
                    {
                        input = input.Where(w => w.ManufacturerUUID != screen.Value).ToList();
                    }
                    else
                    {
                        input = input.Where(w => w.ManufacturerUUID == screen.Value).ToList();
                    }
                    break;

                case "DEPARTMENT":
                    if (screen.Command.EqualsIgnoreCase("CONTAINS"))
                    {
                        input = input.Where(w => w.DepartmentUUID?.ToUpper().Contains(screen.Value.ToUpper())).ToList();
                    }
                    else if (screen.Command.EqualsIgnoreCase("SEARCH!BY"))
                    {
                        input = input.Where(w => w.DepartmentUUID != screen.Value).ToList();
                    }
                    else
                    {
                        input = input.Where(w => w.DepartmentUUID == screen.Value).ToList();
                    }
                    break;


                case "GROWER":

                    if (screen.Command.EqualsIgnoreCase("SEARCH!BY"))
                    {
                        input = input.Where(w => w.Grower != screen.Value).ToList();
                    }
                    else
                    {
                        input = input.Where(w => w.Grower == true).ToList();
                    }
                    break;

                case "DISPENSARY":

                    if (screen.Command.EqualsIgnoreCase("SEARCH!BY"))
                    {
                        input = input.Where(w => w.Dispensary != screen.Value).ToList();
                    }
                    else
                    {
                        input = input.Where(w => w.Dispensary == true).ToList();
                    }
                    break;

                case "BREEDERTYPE":
                    if (screen.Command.EqualsIgnoreCase("CONTAINS"))
                    {
                        input = input.Where(w => w.BreederType?.ToUpper().Contains(screen.Value.ToUpper())).ToList();
                    }
                    else if (screen.Command.EqualsIgnoreCase("SEARCH!BY"))
                    {
                        input = input.Where(w => w.BreederType?.ToUpper() != screen.Value).ToList();
                    }
                    else
                    {
                        input = input.Where(w => StringEx.EqualsEx(w.BreederType, screen.Value)).ToList();
                    }
                    break;

                //Units Of Measure
                case "CATEGORYUUID":
                    if (screen.Command.EqualsIgnoreCase("CONTAINS"))
                    {
                        input = input.Where(w => w.CategoryUUID?.ToUpper().Contains(screen.Value.ToUpper())).ToList();
                    }
                    else if (screen.Command.EqualsIgnoreCase("SEARCH!BY"))
                    {
                        input = input.Where(w => w.CategoryUUID != screen.Value).ToList();
                    }
                    else
                    {
                        input = input.Where(w => w.CategoryUUID == screen.Value).ToList();
                    }
                    break;
                }
            }
            catch (Exception ex)
            {
                Debug.Assert(false, ex.Message);
            }
            return(input);
        }
Beispiel #7
0
        public override void SaveTemporaryMap()
        {
            FileStream   FS = new FileStream("User Data/Saves/TempSave.sav", FileMode.Create, FileAccess.Write);
            BinaryWriter BW = new BinaryWriter(FS);

            BW.Write(BattleMapPath);
            BW.Write(typeof(DeathmatchMap).AssemblyQualifiedName);

            DataScreen.SaveProgression(BW, PlayerRoster);

            BW.Write(DicMapVariables.Count);
            foreach (KeyValuePair <string, double> Variables in DicMapVariables)
            {
                BW.Write(Variables.Key);
                BW.Write(Variables.Value);
            }

            BW.Write(CursorPosition.X);
            BW.Write(CursorPosition.Y);

            BW.Write(CameraPosition.X);
            BW.Write(CameraPosition.Y);

            BW.Write(ActivePlayerIndex);
            BW.Write(GameTurn);
            BW.Write(VictoryCondition);
            BW.Write(LossCondition);
            BW.Write(SkillPoint);

            BW.Write(ListBackground.Count);
            for (int B = 0; B < ListBackground.Count; ++B)
            {
                BW.Write(ListBackground[B].AnimationFullPath);
            }
            BW.Write(ListForeground.Count);
            for (int F = 0; F < ListForeground.Count; ++F)
            {
                BW.Write(ListForeground[F].AnimationFullPath);
            }

            BW.Write(sndBattleThemeName);

            BW.Write(FMODSystem.sndActiveBGMName);
            BW.Write(FMODSystem.GetPosition(FMODSystem.sndActiveBGM));

            BW.Write(ListPlayer.Count);
            foreach (Player ActivePlayer in ListPlayer)
            {
                BW.Write(ActivePlayer.Name);
                BW.Write(ActivePlayer.OnlinePlayerType);
                BW.Write(ActivePlayer.IsPlayerControlled);
                BW.Write(ActivePlayer.Team);
                BW.Write(ActivePlayer.Color.R);
                BW.Write(ActivePlayer.Color.G);
                BW.Write(ActivePlayer.Color.B);

                BW.Write(ActivePlayer.ListSquad.Count);
                foreach (Squad ActiveSquad in ActivePlayer.ListSquad)
                {
                    BW.Write(ActiveSquad.ID);
                    BW.Write(ActiveSquad.CanMove);
                    BW.Write(ActiveSquad.ActionsRemaining);
                    BW.Write(ActiveSquad.X);
                    BW.Write(ActiveSquad.Y);
                    BW.Write(ActiveSquad.Z);
                    BW.Write(ActiveSquad.SquadName);
                    BW.Write(ActiveSquad.CurrentMovement);
                    BW.Write(ActiveSquad.IsFlying);
                    BW.Write(ActiveSquad.IsUnderTerrain);
                    BW.Write(ActiveSquad.IsPlayerControlled);
                    if (ActiveSquad.SquadAI == null || ActiveSquad.SquadAI.Path == null)
                    {
                        BW.Write(string.Empty);
                    }
                    else
                    {
                        BW.Write(ActiveSquad.SquadAI.Path);
                    }

                    int UnitsInSquad = ActiveSquad.UnitsInSquad;

                    BW.Write(UnitsInSquad);
                    BW.Write(ActiveSquad.CurrentLeaderIndex);
                    BW.Write(ActiveSquad.CurrentWingmanAIndex);
                    BW.Write(ActiveSquad.CurrentWingmanBIndex);

                    for (int U = 0; U < UnitsInSquad; ++U)
                    {
                        ActiveSquad.At(U).QuickSave(BW);
                    }

                    //List of Attacked Teams.
                    BW.Write(ActiveSquad.ListAttackedTeam.Count);
                    for (int U = 0; U < ActiveSquad.ListAttackedTeam.Count; ++U)
                    {
                        BW.Write(ActiveSquad.ListAttackedTeam[U]);
                    }
                }
            }

            for (int P = 0; P < ListPlayer.Count; P++)
            {
                for (int S = 0; S < ListPlayer[P].ListSquad.Count; S++)
                {
                    if (!ListPlayer[P].ListSquad[S].IsDead)
                    {
                        for (int U = 0; U < ListPlayer[P].ListSquad[S].UnitsInSquad; ++U)
                        {
                            for (int C = 0; C < ListPlayer[P].ListSquad[S].At(U).ArrayCharacterActive.Length; C++)
                            {
                                Character ActiveCharacter = ListPlayer[P].ListSquad[S].At(U).ArrayCharacterActive[C];
                                ActiveCharacter.Effects.QuickSave(BW);
                            }
                        }
                    }
                }
            }

            BW.Write(ListMapScript.Count);
            for (int S = 0; S < ListMapScript.Count; S++)
            {
                ListMapScript[S].Save(BW);
            }

            FS.Close();
            BW.Close();
        }
Beispiel #8
0
        public override BattleMap LoadTemporaryMap(BinaryReader BR)
        {
            PlayerRoster = new Roster();
            PlayerRoster.LoadRoster();

            Load();
            DataScreen.LoadProgression(BR, PlayerRoster, DicUnitType, DicRequirement, DicEffect, DicAutomaticSkillTarget, DicManualSkillTarget);

            //Initialise the ScreenSize based on the map loaded.
            ScreenSize = new Point(Constants.Width / TileSize.X, Constants.Height / TileSize.Y);

            IsInit           = true;
            RequireDrawFocus = false;

            TogglePreview(true);

            int DicMapVariablesCount = BR.ReadInt32();

            DicMapVariables = new Dictionary <string, double>(DicMapVariablesCount);
            for (int i = 0; i < DicMapVariablesCount; ++i)
            {
                DicMapVariables.Add(BR.ReadString(), BR.ReadDouble());
            }

            CursorPosition.X = BR.ReadSingle();
            CursorPosition.Y = BR.ReadSingle();

            CameraPosition.X = BR.ReadSingle();
            CameraPosition.Y = BR.ReadSingle();

            ActivePlayerIndex = BR.ReadInt32();
            GameTurn          = BR.ReadInt32();

            VictoryCondition = BR.ReadString();
            LossCondition    = BR.ReadString();
            SkillPoint       = BR.ReadString();

            ListBackground.Clear();
            int ListBackgroundCount = BR.ReadInt32();

            for (int B = 0; B < ListBackgroundCount; ++B)
            {
                ListBackground.Add(AnimationBackground.LoadAnimationBackground(BR.ReadString(), Content, GraphicsDevice));
            }

            ListForeground.Clear();
            int ListForegroundCount = BR.ReadInt32();

            for (int F = 0; F < ListForegroundCount; ++F)
            {
                ListForeground.Add(AnimationBackground.LoadAnimationBackground(BR.ReadString(), Content, GraphicsDevice));
            }

            sndBattleThemeName = BR.ReadString();
            if (!string.IsNullOrEmpty(sndBattleThemeName))
            {
                FMODSound NewBattleTheme = new FMODSound(FMODSystem, "Content/Maps/BGM/" + sndBattleThemeName + ".mp3");

                NewBattleTheme.SetLoop(true);
                sndBattleTheme = NewBattleTheme;
            }

            string ThemePath     = BR.ReadString();
            uint   ThemePosition = BR.ReadUInt32();

            if (!string.IsNullOrEmpty(ThemePath))
            {
                FMODSound NewTheme = new FMODSound(FMODSystem, "Content/Maps/BGM/" + ThemePath + ".mp3");
                NewTheme.SetLoop(true);
                NewTheme.PlayAsBGM();
                FMODSystem.sndActiveBGMName = ThemePath;
                NewTheme.SetPosition(ThemePosition);
            }

            Dictionary <uint, Squad> DicLoadedSquad = new Dictionary <uint, Squad>();

            int ListPlayerCount = BR.ReadInt32();

            ListPlayer = new List <Player>(ListPlayerCount);
            for (int P = 0; P < ListPlayerCount; ++P)
            {
                string ActivePlayerName       = BR.ReadString();
                string ActivePlayerType       = BR.ReadString();
                bool   ActivePlayerIsHuman    = BR.ReadBoolean();
                int    ActivePlayerTeam       = BR.ReadInt32();
                byte   ActivePlayerColorRed   = BR.ReadByte();
                byte   ActivePlayerColorGreen = BR.ReadByte();
                byte   ActivePlayerColorBlue  = BR.ReadByte();

                Player NewPlayer = new Player(ActivePlayerName, ActivePlayerType, ActivePlayerIsHuman, false, ActivePlayerTeam,
                                              Color.FromNonPremultiplied(ActivePlayerColorRed, ActivePlayerColorGreen, ActivePlayerColorBlue, 255));

                ListPlayer.Add(NewPlayer);

                int ActivePlayerListSquadCount = BR.ReadInt32();
                for (int S = 0; S < ActivePlayerListSquadCount; ++S)
                {
                    Squad  NewSquad;
                    UInt32 ActiveSquadID                 = BR.ReadUInt32();
                    bool   CanMove                       = BR.ReadBoolean();
                    int    ActionsRemaining              = BR.ReadInt32();
                    float  ActiveSquadPositionX          = BR.ReadSingle();
                    float  ActiveSquadPositionY          = BR.ReadSingle();
                    float  ActiveSquadPositionZ          = BR.ReadSingle();
                    string ActiveSquadSquadName          = BR.ReadString();
                    string ActiveSquadCurrentMovement    = BR.ReadString();
                    bool   ActiveSquadIsFlying           = BR.ReadBoolean();
                    bool   ActiveSquadIsUnderTerrain     = BR.ReadBoolean();
                    bool   ActiveSquadIsPlayerControlled = BR.ReadBoolean();
                    string ActiveSquadSquadAI            = BR.ReadString();

                    int ActiveSquadUnitsInSquad = BR.ReadInt32();
                    int CurrentLeaderIndex      = BR.ReadInt32();
                    int CurrentWingmanAIndex    = BR.ReadInt32();
                    int CurrentWingmanBIndex    = BR.ReadInt32();

                    Unit[] ArrayNewUnit = new Unit[ActiveSquadUnitsInSquad];
                    for (int U = 0; U < ActiveSquadUnitsInSquad; ++U)
                    {
                        string UnitTypeName = BR.ReadString();
                        string RelativePath = BR.ReadString();
                        string TeamEventID  = BR.ReadString();

                        if (string.IsNullOrEmpty(TeamEventID))
                        {
                            ArrayNewUnit[U] = DicUnitType[UnitTypeName].FromFile(RelativePath, Content, DicRequirement, DicEffect, DicAutomaticSkillTarget);
                        }
                        else
                        {
                            foreach (Unit ActiveUnit in PlayerRoster.TeamUnits.GetAll())
                            {
                                if (ActiveUnit.TeamEventID == TeamEventID)
                                {
                                    ArrayNewUnit[U] = ActiveUnit;
                                    break;
                                }
                            }
                        }

                        ArrayNewUnit[U].QuickLoad(BR, Content, DicRequirement, DicEffect, DicAutomaticSkillTarget, DicManualSkillTarget);
                    }

                    NewSquad = new Squad(ActiveSquadSquadName, ArrayNewUnit[0],
                                         ArrayNewUnit.Length >= 2 ? ArrayNewUnit[1] : null,
                                         ArrayNewUnit.Length >= 3 ? ArrayNewUnit[2] : null);

                    int ListAttackedTeamCount = BR.ReadInt32();
                    NewSquad.ListAttackedTeam = new List <int>(ListAttackedTeamCount);
                    for (int U = 0; U < ListAttackedTeamCount; ++U)
                    {
                        NewSquad.ListAttackedTeam.Add(BR.ReadInt32());
                    }

                    NewSquad.SetLeader(CurrentLeaderIndex);
                    NewSquad.SetWingmanA(CurrentWingmanAIndex);
                    NewSquad.SetWingmanB(CurrentWingmanBIndex);

                    if (!CanMove)
                    {
                        NewSquad.EndTurn();
                    }

                    NewSquad.ActionsRemaining = ActionsRemaining;
                    NewSquad.SquadName        = ActiveSquadSquadName;
                    NewSquad.ID = ActiveSquadID;

                    DicLoadedSquad.Add(ActiveSquadID, NewSquad);

                    if (NewSquad.CurrentLeader != null)
                    {
                        //Do not spawn squads as it will trigger effect that were already activated
                        if (Content != null)
                        {
                            NewSquad.Unit3D = new UnitMap3D(GraphicsDevice, Content.Load <Effect>("Shaders/Squad shader 3D"), NewSquad.CurrentLeader.SpriteMap, 1);
                        }

                        if (!string.IsNullOrEmpty(ActiveSquadSquadAI))
                        {
                            NewSquad.SquadAI = new DeathmatchScripAIContainer(new DeathmatchAIInfo(this, NewSquad));
                            NewSquad.SquadAI.Load(ActiveSquadSquadAI);
                        }

                        NewPlayer.IsAlive = true;

                        ActivateAutomaticSkills(NewSquad, string.Empty);
                    }

                    NewSquad.UpdateSquad();

                    //Load the Battle Themes.
                    for (int U = 0; U < NewSquad.UnitsInSquad; ++U)
                    {
                        for (int C = NewSquad.At(U).ArrayCharacterActive.Length - 1; C >= 0; --C)
                        {
                            if (!string.IsNullOrEmpty(NewSquad.At(U).ArrayCharacterActive[C].BattleThemeName))
                            {
                                if (!Character.DicBattleTheme.ContainsKey(NewSquad.At(U).ArrayCharacterActive[C].BattleThemeName))
                                {
                                    Character.DicBattleTheme.Add(NewSquad.At(U).ArrayCharacterActive[C].BattleThemeName, new FMODSound(FMODSystem, "Content/Maps/BGM/" + NewSquad.At(U).ArrayCharacterActive[C].BattleThemeName + ".mp3"));
                                }
                            }
                        }
                    }

                    NewSquad.CurrentMovement    = ActiveSquadCurrentMovement;
                    NewSquad.IsFlying           = ActiveSquadIsFlying;
                    NewSquad.IsUnderTerrain     = ActiveSquadIsUnderTerrain;
                    NewSquad.IsPlayerControlled = ActiveSquadIsPlayerControlled;
                    NewSquad.SetPosition(new Vector3(ActiveSquadPositionX, ActiveSquadPositionY, ActiveSquadPositionZ));
                    NewPlayer.ListSquad.Add(NewSquad);
                }
            }

            GlobalQuickLoadContext.SetContext(DicLoadedSquad);

            for (int P = 0; P < ListPlayer.Count; P++)
            {
                for (int S = 0; S < ListPlayer[P].ListSquad.Count; S++)
                {
                    if (!ListPlayer[P].ListSquad[S].IsDead)
                    {
                        for (int U = 0; U < ListPlayer[P].ListSquad[S].UnitsInSquad; ++U)
                        {
                            for (int C = 0; C < ListPlayer[P].ListSquad[S].At(U).ArrayCharacterActive.Length; C++)
                            {
                                Character ActiveCharacter = ListPlayer[P].ListSquad[S].At(U).ArrayCharacterActive[C];
                                ActiveCharacter.Effects.QuickLoad(BR, ActiveParser, DicRequirement, DicEffect, DicAutomaticSkillTarget);
                            }
                        }
                    }
                }
            }

            for (int P = 0; P < ListPlayer.Count; ++P)
            {
                for (int S = 0; S < ListPlayer[P].ListSquad.Count; ++S)
                {
                    ListPlayer[P].ListSquad[S].ReloadSkills(DicUnitType, DicRequirement, DicEffect, DicAutomaticSkillTarget, DicManualSkillTarget);
                }
            }

            int ListMapScriptCount = BR.ReadInt32();

            if (ListMapScript.Count != ListMapScriptCount)
            {
                throw new Exception("An error occured while loading the map.");
            }

            for (int S = 0; S < ListMapScript.Count; S++)
            {
                ListMapScript[S].Load(BR);
            }

            ListActionMenuChoice.Add(new ActionPanelPhaseChange(this));

            return(this);
        }