Пример #1
0
    private void CreateRandomComposition() {
        IPlayer owner;
        if (!__isHumanFleetCreated) {
            owner = GameManager.Instance.HumanPlayer;
            __isHumanFleetCreated = true;
        }
        else {
            owner = new Player(new Race(Enums<Races>.GetRandom(excludeDefault: true)), IQ.Normal);
        }
        _composition = new StarbaseComposition();

        FacilityCategory[] __hullsToConsider = new FacilityCategory[] { FacilityCategory.CentralHub, FacilityCategory.Construction, FacilityCategory.Economic, FacilityCategory.Science, FacilityCategory.Defense };

        //determine how many ships of what hull for the fleet, then build shipdata and add to composition
        int shipCount = RandomExtended<int>.Range(1, maxShips);
        for (int i = 0; i < shipCount; i++) {
            FacilityCategory hull = RandomExtended<FacilityCategory>.Choice(__hullsToConsider);
            int shipHullIndex = GetShipHullIndex(hull);
            string shipName = hull.GetName() + Constants.Underscore + shipHullIndex;
            FacilityData shipData = CreateShipData(hull, shipName, owner);
            _composition.Add(shipData);
        }
    }
Пример #2
0
 private int GetShipHullIndex(FacilityCategory hull) {
     if (!_composition.ElementCategories.Contains(hull)) {
         return 1;
     }
     return _composition.GetData(hull).Count + 1;
 }
Пример #3
0
 public static ArrangeControlsEventArgs Make(FacilityCategory cat, Configuration cfg)
 {
     return(new ArrangeControlsEventArgs {
         Category = cat, Config = cfg
     });
 }
Пример #4
0
 private FacilityData CreateShipData(FacilityCategory hull, string shipName, IPlayer owner) {
     FacilityData shipData = new FacilityData(hull, shipName, 50F, mass: 10000F) {   // TODO mass variation
         // Ship's optionalParentName gets set when it gets attached to a fleet
         Strength = new CombatStrength(),
         CurrentHitPoints = UnityEngine.Random.Range(25F, 50F),
         Owner = owner,
     };
     return shipData;
 }
Пример #5
0
        private void ArrangeControls(FacilityCategory cat, Configuration cfg)
        {
            switch (cfg)
            {
                #region Config A
            case cfgA:
                switch (cat)
                {
                case slpdFclty:
                    DisplayAGControls(new AGCtrls {
                        { AGP.OFH, ptUR }
                    });
                    DisplayBGControls(new BGCtrls {
                        { BGP.IP, ptTL }, { BGP.C2S, ptTR }
                    });
                    break;

                case fltPntr:
                    DisplayAGControls(
                        new AGCtrls {
                        { AGP.BA, ptUR },
                        { AGP.OFH, ptTL }, { AGP.ABW, ptTR }
                    });
                    DisplayBGControls(new BGCtrls {
                        { BGP.IP, ptTL }, { BGP.C2S, ptTR }
                    });
                    break;

                case rectBasin:
                    DisplayAGControls(
                        new AGCtrls {
                        { AGP.BA, ptUR },
                        { AGP.SS, ptTL }, { AGP.FD, ptTR },
                        { AGP.OFH, ptML }, { AGP.ABW, ptMR }
                    }, true);
                    DisplayBGControls(new BGCtrls {
                        { BGP.IP, ptTL }, { BGP.C2S, ptTR }
                    });
                    break;

                case amoebaBasin:
                    DisplayAGControls(
                        new AGCtrls {
                        { AGP.BA, ptUR },
                        { AGP.SS, ptTL }, { AGP.FD, ptTR },
                        { AGP.OFH, ptML }, { AGP.BP, ptMR }
                    }, true);
                    DisplayBGControls(new BGCtrls {
                        { BGP.IP, ptTL }, { BGP.C2S, ptTR }
                    });
                    break;

                case usrBasin:
                    DisplayAGControls(
                        new AGCtrls {
                        { AGP.BA, ptUR },
                        { AGP.OFH, ptTL }, { AGP.OFA, ptTR }
                    }, true);
                    DisplayBGControls(new BGCtrls {
                        { BGP.IP, ptTL }, { BGP.C2S, ptTR }
                    });
                    break;
                }
                #endregion Config A
                break;

                #region Config B
            case cfgB:
                switch (cat)
                {
                case slpdFclty:
                    DisplayAGControls(AGCtrls.Empty);
                    DisplayBGControls(
                        new BGCtrls {
                        { BGP.IP, ptTL }, { BGP.C2S, ptTR },
                        { BGP.RSD, ptML }, { BGP.RP, ptMR },
                        { BGP.RAW, raw3 }
                    }, false);
                    break;

                case fltPntr:
                    DisplayAGControls(
                        new AGCtrls {
                        { AGP.BA, ptUR },
                        { AGP.OFH, ptTL }, { AGP.ABW, ptTR }
                    });
                    DisplayBGControls(
                        new BGCtrls {
                        { BGP.IP, ptTL }, { BGP.C2S, ptTR },
                        { BGP.RSD, ptML }, { BGP.RP, ptMR },
                        { BGP.RAW, raw3 }
                    }, false);
                    break;

                case rectBasin:
                    DisplayAGControls(
                        new AGCtrls {
                        { AGP.BA, ptUR },
                        { AGP.ABW, ptTL }, { AGP.OFH, ptTR },
                        { AGP.SS, ptML }, { AGP.FD, ptMR }
                    }, true);
                    DisplayBGControls(
                        new BGCtrls {
                        { BGP.IP, ptTL }, { BGP.C2S, ptTR },
                        { BGP.RSD, ptML }, { BGP.RP, ptMR },
                        { BGP.RAW, raw3 }
                    }, false);
                    break;

                case amoebaBasin:
                    DisplayAGControls(
                        new AGCtrls {
                        { AGP.BA, ptUR },
                        { AGP.BP, ptTL }, { AGP.OFH, ptTR },
                        { AGP.SS, ptML }, { AGP.FD, ptMR }
                    }, true);
                    DisplayBGControls(
                        new BGCtrls {
                        { BGP.IP, ptTL }, { BGP.C2S, ptTR },
                        { BGP.RSD, ptML }, { BGP.RP, ptMR },
                        { BGP.RAW, raw3 }
                    }, false);
                    break;

                case usrBasin:
                    DisplayAGControls(
                        new AGCtrls {
                        { AGP.BA, ptUR },
                        { AGP.OFH, ptTL }, { AGP.OFA, ptTR }
                    }, true);
                    DisplayBGControls(
                        new BGCtrls {
                        { BGP.IP, ptTL }, { BGP.C2S, ptTR },
                        { BGP.RSD, ptML }, { BGP.RP, ptMR },
                        { BGP.RAW, raw3 }
                    }, false);
                    break;
                }
                #endregion Config B
                break;

                #region Config C
            case cfgC:
                switch (cat)
                {
                case slpdFclty:
                    DisplayAGControls(AGCtrls.Empty);
                    DisplayBGControls(
                        new BGCtrls {
                        { BGP.RSD, ptTL }, { BGP.IP, ptTR },
                        { BGP.RP, ptML }, { BGP.UDH, ptMR },
                        { BGP.ORF, ptBL }, { BGP.RAW, raw5 }
                    }, false);
                    break;

                case fltPntr:
                    DisplayAGControls(
                        new AGCtrls {
                        { AGP.BA, ptUR },
                        { AGP.OFH, ptTL }, { AGP.ABW, ptTR }
                    });
                    DisplayBGControls(
                        new BGCtrls {
                        { BGP.RSD, ptTL }, { BGP.IP, ptTR },
                        { BGP.RP, ptML }, { BGP.UDH, ptMR },
                        { BGP.ORF, ptBL }, { BGP.RAW, raw5 }
                    });
                    break;

                case rectBasin:
                    DisplayAGControls(
                        new AGCtrls {
                        { AGP.BA, ptUR },
                        { AGP.ABW, ptTL }, { AGP.OFH, ptTR },
                        { AGP.SS, ptML }, { AGP.FD, ptMR }
                    }, true);
                    DisplayBGControls(
                        new BGCtrls {
                        { BGP.RSD, ptTL }, { BGP.IP, ptTR },
                        { BGP.RP, ptML }, { BGP.UDH, ptMR },
                        { BGP.ORF, ptBL }, { BGP.RAW, raw5 }
                    });
                    break;

                case amoebaBasin:
                    DisplayAGControls(
                        new AGCtrls {
                        { AGP.BA, ptUR },
                        { AGP.BP, ptTL }, { AGP.OFH, ptTR },
                        { AGP.SS, ptML }, { AGP.FD, ptMR }
                    }, true);
                    DisplayBGControls(
                        new BGCtrls {
                        { BGP.RSD, ptTL }, { BGP.IP, ptTR },
                        { BGP.RP, ptML }, { BGP.UDH, ptMR },
                        { BGP.ORF, ptBL }, { BGP.RAW, raw5 }
                    });
                    break;

                case usrBasin:
                    DisplayAGControls(
                        new AGCtrls {
                        { AGP.BA, ptUR },
                        { AGP.OFH, ptTL }, { AGP.OFA, ptTR }
                    }, true);
                    DisplayBGControls(
                        new BGCtrls {
                        { BGP.RSD, ptTL }, { BGP.IP, ptTR },
                        { BGP.RP, ptML }, { BGP.UDH, ptMR },
                        { BGP.ORF, ptBL }, { BGP.RAW, raw5 }
                    });
                    break;
                }
                #endregion Config C
                break;

                #region Config D
            case cfgD:
                switch (cat)
                {
                case slpdFclty:
                    DisplayAGControls(AGCtrls.Empty);
                    DisplayBGControls(
                        new BGCtrls {
                        { BGP.RSD, ptUR },
                        { BGP.RP, ptTL }, { BGP.UDH, ptTR },
                        { BGP.ORF, ptML }, { BGP.RAW, raw4 }
                    }, false);
                    break;

                case fltPntr:
                    DisplayAGControls(
                        new AGCtrls {
                        { AGP.BA, ptUR },
                        { AGP.OFH, ptTL }, { AGP.ABW, ptTR }
                    });
                    DisplayBGControls(
                        new BGCtrls {
                        { BGP.RSD, ptUR },
                        { BGP.RP, ptTL }, { BGP.UDH, ptTR },
                        { BGP.ORF, ptML }, { BGP.RAW, raw4 }
                    });
                    break;

                case rectBasin:
                    DisplayAGControls(
                        new AGCtrls {
                        { AGP.BA, ptTL }, { AGP.ABW, ptTR },
                        { AGP.SS, ptML }, { AGP.FD, ptMR },
                        { AGP.OFH, ptBL }
                    }, true);
                    DisplayBGControls(
                        new BGCtrls {
                        { BGP.RSD, ptUR },
                        { BGP.RP, ptTL }, { BGP.UDH, ptTR },
                        { BGP.ORF, ptML }, { BGP.RAW, raw4 }
                    }); break;

                case amoebaBasin:
                    DisplayAGControls(
                        new AGCtrls {
                        { AGP.BA, ptUR },
                        { AGP.BP, ptTL }, { AGP.OFH, ptTR },
                        { AGP.SS, ptML }, { AGP.FD, ptMR }
                    }, true);
                    DisplayBGControls(
                        new BGCtrls {
                        { BGP.RSD, ptUR },
                        { BGP.RP, ptTL }, { BGP.UDH, ptTR },
                        { BGP.ORF, ptML }, { BGP.RAW, raw4 }
                    });
                    break;

                case usrBasin:
                    DisplayAGControls(
                        new AGCtrls {
                        { AGP.BA, ptUR },
                        { AGP.OFH, ptTL }, { AGP.OFA, ptTR }
                    }, true);
                    DisplayBGControls(
                        new BGCtrls {
                        { BGP.RSD, ptUR },
                        { BGP.RP, ptTL }, { BGP.UDH, ptTR },
                        { BGP.ORF, ptML }, { BGP.RAW, raw4 }
                    });
                    break;
                }
                #endregion Config D
                break;

                #region Config E
            case cfgE:
                switch (cat)
                {
                case slpdFclty:
                    DisplayAGControls(new AGCtrls {
                        { AGP.OFEH, ptUR }
                    });
                    DisplayBGControls(
                        new BGCtrls {
                        { BGP.IP, ptTL }, { BGP.C2S, ptTR },
                        { BGP.RSD, ptML }, { BGP.RP, ptMR },
                        { BGP.RAW, raw3 }
                    }, false);
                    break;

                case fltPntr:
                    DisplayAGControls(
                        new AGCtrls {
                        { AGP.BA, ptTL }, { AGP.ABW, ptTR },
                        { AGP.OFH, ptML }, { AGP.OFEH, ptMR }
                    });
                    DisplayBGControls(
                        new BGCtrls {
                        { BGP.IP, ptTL }, { BGP.C2S, ptTR },
                        { BGP.RSD, ptML }, { BGP.RP, ptMR },
                        { BGP.RAW, raw3 }
                    }, false);
                    break;

                case rectBasin:
                    DisplayAGControls(
                        new AGCtrls {
                        { AGP.BA, ptTL }, { AGP.ABW, ptTR },
                        { AGP.SS, ptML }, { AGP.FD, ptMR },
                        { AGP.OFH, ptBL }, { AGP.OFEH, ptBR }
                    }, true);
                    DisplayBGControls(
                        new BGCtrls {
                        { BGP.IP, ptTL }, { BGP.C2S, ptTR },
                        { BGP.RSD, ptML }, { BGP.RP, ptMR },
                        { BGP.RAW, raw3 }
                    }, false);
                    break;

                case amoebaBasin:
                    DisplayAGControls(
                        new AGCtrls {
                        { AGP.BA, ptTL }, { AGP.BP, ptTR },
                        { AGP.SS, ptML }, { AGP.FD, ptMR },
                        { AGP.OFH, ptBL }, { AGP.OFEH, ptBR }
                    }, true);
                    DisplayBGControls(
                        new BGCtrls {
                        { BGP.IP, ptTL }, { BGP.C2S, ptTR },
                        { BGP.RSD, ptML }, { BGP.RP, ptMR },
                        { BGP.RAW, raw3 }
                    }, false);
                    break;

                case usrBasin:
                    DisplayAGControls(
                        new AGCtrls {
                        { AGP.BA, ptUR },
                        { AGP.OFH, ptTL }, { AGP.OFA, ptTR },
                        { AGP.OFEH, ptML }, { AGP.OFEA, ptMR }
                    }, true);
                    DisplayBGControls(
                        new BGCtrls {
                        { BGP.IP, ptTL }, { BGP.C2S, ptTR },
                        { BGP.RSD, ptML }, { BGP.RP, ptMR },
                        { BGP.RAW, raw3 }
                    }, false);
                    break;
                }
                #endregion Config E
                break;

                #region Config F
            case cfgF:
                switch (cat)
                {
                case slpdFclty:
                    DisplayAGControls(AGCtrls.Empty);
                    DisplayBGControls(
                        new BGCtrls {
                        { BGP.C2S, ptUR },
                        { BGP.RSD, ptTL }, { BGP.IP, ptTR },
                        { BGP.RP, ptML }, { BGP.UDH, ptMR },
                        { BGP.RAW, raw3 }
                    }, false);
                    break;

                case fltPntr:
                    DisplayAGControls(
                        new AGCtrls {
                        { AGP.BA, ptUR },
                        { AGP.ABW, ptTL }, { AGP.OFH, ptTR }
                    });
                    DisplayBGControls(
                        new BGCtrls {
                        { BGP.C2S, ptUR },
                        { BGP.RSD, ptTL }, { BGP.IP, ptTR },
                        { BGP.RP, ptML }, { BGP.UDH, ptMR },
                        { BGP.RAW, raw3 }
                    });
                    break;

                case rectBasin:
                    DisplayAGControls(
                        new AGCtrls {
                        { AGP.BA, ptUR },
                        { AGP.ABW, ptTL }, { AGP.OFH, ptTR },
                        { AGP.SS, ptML }, { AGP.FD, ptMR }
                    }, true);
                    DisplayBGControls(
                        new BGCtrls {
                        { BGP.C2S, ptUR },
                        { BGP.RSD, ptTL }, { BGP.IP, ptTR },
                        { BGP.RP, ptML }, { BGP.UDH, ptMR },
                        { BGP.RAW, raw3 }
                    });
                    break;

                case amoebaBasin:
                    DisplayAGControls(
                        new AGCtrls {
                        { AGP.BA, ptUR },
                        { AGP.SS, ptTL }, { AGP.FD, ptTR },
                        { AGP.OFH, ptML }, { AGP.BP, ptMR }
                    }, true);
                    DisplayBGControls(
                        new BGCtrls {
                        { BGP.C2S, ptUR },
                        { BGP.RSD, ptTL }, { BGP.IP, ptTR },
                        { BGP.RP, ptML }, { BGP.UDH, ptMR },
                        { BGP.RAW, raw3 }
                    });
                    break;

                case usrBasin:
                    DisplayAGControls(
                        new AGCtrls {
                        { AGP.BA, ptUR },
                        { AGP.OFH, ptTL }, { AGP.OFA, ptTR }
                    }, true);
                    DisplayBGControls(
                        new BGCtrls {
                        { BGP.C2S, ptUR },
                        { BGP.RSD, ptTL }, { BGP.IP, ptTR },
                        { BGP.RP, ptML }, { BGP.UDH, ptMR },
                        { BGP.RAW, raw3 }
                    });
                    break;
                }
                #endregion Config F
                break;
            }
            var isSloped = cat == FacilityCategory.SlopedFacility;

            SegPanel.Visible = isSloped;
            if (!isSloped)
            {
                return;
            }
            // -----------------------------
            SegPanel.Top = BGPanel.Visible ?
                           BGPanel.Top + BGPanel.Height + 10 :
                           AGPanel.Top + AGPanel.Height + 10;
            SegPanel.Height = TabCntrl.Height - SegPanel.Top - 60;
        }