public CombatShip(StrategyGame game, string imageFilename, int width, int height, Color teamColor, int team, int alliance, float health, int numPilots, EShipType type, int sectorId) : base(game, imageFilename, width, height, teamColor, team, alliance, health, numPilots, sectorId) { Type = type; Weapons = new List <Weapon>(); TeamPen = new Pen(Colour.AdjustAlpha(StrategyGame.AbilityPenAlpha), StrategyGame.AbilityPenWidth); // Prepare the abilities this ship can use, adjusted with the current upgrades Abilities = new Dictionary <EAbilityType, Ability>(); var t = team - 1; var cooldown = game.TechTree[t].ResearchedUpgrades[EGlobalUpgrade.AbilityCooldown]; var duration = game.TechTree[t].ResearchedUpgrades[EGlobalUpgrade.AbilityDuration]; var effect = game.TechTree[t].ResearchedUpgrades[EGlobalUpgrade.AbilityEffect]; foreach (var at in game.GetEnabledAbilities(team, type)) { var ad = game.AbilityData[at]; var ab = new Ability(at, cooldown * ad.CooldownDuration, effect * ad.AbilityEffectMultiplier, duration * ad.AbilityDuration); Abilities.Add(at, ab); if (at == EAbilityType.WeaponBoost) { _boostWeaponsAmount = ab.AbilityEffectMultiplier; } // Setup what happens to this ship when the ability is triggered & completes // (Rapid Fire, Weapon Boost, Engine Boost are handled while active, not toggled on/off) if (at == EAbilityType.EngineBoost) { ab.AbilityStarted += (Ability a) => { Speed *= a.AbilityEffectMultiplier; }; ab.AbilityFinished += (Ability a) => { Speed /= a.AbilityEffectMultiplier; }; } else if (at == EAbilityType.ShieldBoost) { ab.AbilityStarted += (Ability a) => { Shield += MaxShield * (a.AbilityEffectMultiplier - 1); if (Shield > MaxShield) { Shield = MaxShield; } }; } else if (at == EAbilityType.ScanBoost) { ab.AbilityStarted += (Ability a) => { ScanRange *= a.AbilityEffectMultiplier; }; ab.AbilityFinished += (Ability a) => { ScanRange /= a.AbilityEffectMultiplier; }; } else if (at == EAbilityType.StealthBoost) { ab.AbilityStarted += (Ability a) => { Signature /= a.AbilityEffectMultiplier; }; ab.AbilityFinished += (Ability a) => { Signature *= a.AbilityEffectMultiplier; }; } } }
public ScoutingMission(StrategyGame game, BaseAI ai, Ship.ShipEventHandler shipEvent) : base(game, ai, shipEvent) { }
public Base(StrategyGame game, EBaseType type, int width, int height, Color teamColor, int team, int alliance, float health, int sectorId) : this(game, string.Empty, type, width, height, teamColor, team, alliance, health, sectorId) { }
public MineOrder(StrategyGame game, int sectorId) : this(game, sectorId, Point.Empty, Point.Empty) { }
public BuilderMission(StrategyGame game, BaseAI ai, Ship.ShipEventHandler shipEvent) : base(game, ai, shipEvent) { }
public BombingMission(StrategyGame game, BaseAI ai, Ship.ShipEventHandler shipHandler) : base(game, ai, shipHandler) { }
public void Setup() { _game = new StrategyGame(); _game.SetupGame(GameSettings.Default()); _game.LoadData(); }
public Asteroid(StrategyGame game, Random r, int width, int height, int sectorId) : this(game, StrategyGame.RockPicDir + Images[r.Next(0, Images.Length)], width, height, sectorId) { }
public Asteroid(StrategyGame game, string imageFilename, int width, int height, int sectorId) : base(game, imageFilename, width, height, sectorId) { Type = EAsteroidType.Generic; }
public ResumeControlOrder(StrategyGame game) : base(game, -1) { }
private ShipSpecs(StrategyGame game, IEnumerable <ShipSpec> items) { Ships = items.ToList(); _game = game; }
public WorldGameListener(StrategyGame game) { _game = game; }
public static SimpleGameMap GenerateMirroredMap(EMapSize size, int numTeams = -1) { var rnd = StrategyGame.Random; var iSize = (int)size; // Lock Large/Small maps to 2/4 teams for less variation if (size == EMapSize.Small) { numTeams = 2; } if (size == EMapSize.Large) { numTeams = 4; } if (numTeams == -1 && size == EMapSize.Normal) { numTeams = rnd.Next(1, 3) * 2; } var map = new SimpleGameMap($"{size} Random{numTeams}"); // 0:hor/1:vert/2:hor&vert var mirrorType = numTeams == 2 ? rnd.Next(3) : 2; var mirrorIncrement = mirrorType == 2 ? 4 : 2; // Determine num sectors based on size & num teams // small: (min = num teams*2, max = num teams*4) // normal: (min = num teams*3, max = num teams*5) // large: (min = num teams*4, max = num teams*6) var minNumSectors = numTeams * (iSize + 2); var maxNumSectors = numTeams * (iSize + 4); var xDim = 7; var yDim = 7; var nextSectorId = 0; // Add sectors in all positions for (var x = 0; x < xDim; x++) { for (var y = 0; y < yDim; y++) { var s = new SimpleMapSector(nextSectorId++, new Point(x, y)); map.Sectors.Add(s); } } var maxChances = map.Sectors.Count * 3; var l = 0; // Loop with a decreasing chance to remove sectors (mirrored) var removeChance = 0.97; while ((l++ < maxChances || map.Sectors.Count - mirrorIncrement > maxNumSectors) && map.Sectors.Count - mirrorIncrement > minNumSectors) { var s = StrategyGame.RandomItem(map.Sectors); if (rnd.NextDouble() < removeChance) { removeChance -= 0.03; map.Sectors.Remove(s); // Horiz mirrored or both if (mirrorType == 0 || mirrorType == 2) { var mX = MirrorDimension(xDim, s.MapPosition.X); var mY = s.MapPosition.Y; var s2 = map.Sectors.FirstOrDefault(_ => _.MapPosition.X == mX && _.MapPosition.Y == mY); if (s2 != null) { map.Sectors.Remove(s2); } } // Vert mirrored or both if (mirrorType == 1 || mirrorType == 2) { var mX = s.MapPosition.X; var mY = MirrorDimension(yDim, s.MapPosition.Y); var s2 = map.Sectors.FirstOrDefault(_ => _.MapPosition.X == mX && _.MapPosition.Y == mY); if (s2 != null) { map.Sectors.Remove(s2); } } // Mirrored for both dimensions if (mirrorType == 2) { var mX = MirrorDimension(xDim, s.MapPosition.X); var mY = MirrorDimension(yDim, s.MapPosition.Y); var s2 = map.Sectors.FirstOrDefault(_ => _.MapPosition.X == mX && _.MapPosition.Y == mY); if (s2 != null) { map.Sectors.Remove(s2); } } } } // Fix SectorIDs after removing, they actually need to be indexes... l = 0; foreach (var s in map.Sectors) { s.Id = l++; } // Triangulate, loop with a small chance to remove an edges if that sector has > 2 connections var vertices = new List <Vertex <SimpleMapSector> >(); foreach (var s in map.Sectors) { var p = s.MapPosition; vertices.Add(new Vertex <SimpleMapSector>(new Vector2(p.X, p.Y), s)); } var delaunay = Delaunay2D <SimpleMapSector> .Triangulate(vertices); var mapEdges = new List <Edge <SimpleMapSector> >(); foreach (var edge in delaunay.Edges) { if (!map.WormholeExists(edge.U.Item.Id, edge.V.Item.Id)) { map.WormholeIds.Add(new WormholeId(edge.U.Item.Id, edge.V.Item.Id)); } } // Find Starting Positions (mirrored) var teamsAdded = 0; { var startPosMinX = 0; var startPosMinY = 0; var startPosMaxX = mirrorType == 1 ? xDim : xDim / 2 - 1; var startPosMaxY = mirrorType == 0 ? yDim : yDim / 2 - 1; var startSectors = map.Sectors .Where(_ => _.MapPosition.X >= startPosMinX && _.MapPosition.X <= startPosMaxX && _.MapPosition.Y >= startPosMinY && _.MapPosition.Y <= startPosMaxY) .ToList(); var s = StrategyGame.RandomItem(startSectors); // Safety check if (s == null) { return(GenerateMirroredMap(size)); } s.StartingSectorTeam = ++teamsAdded; // Mirrored for both dimensions if (mirrorType == 2) { var mX = MirrorDimension(xDim, s.MapPosition.X); var mY = MirrorDimension(yDim, s.MapPosition.Y); var s2 = map.Sectors.FirstOrDefault(_ => _.MapPosition.X == mX && _.MapPosition.Y == mY); if (s2 != null) { s2.StartingSectorTeam = ++teamsAdded; } } // Horiz mirrored or both if (mirrorType == 0 || (mirrorType == 2 && numTeams > 2)) { var mX = MirrorDimension(xDim, s.MapPosition.X); var mY = s.MapPosition.Y; var s2 = map.Sectors.FirstOrDefault(_ => _.MapPosition.X == mX && _.MapPosition.Y == mY); if (s2 != null) { s2.StartingSectorTeam = ++teamsAdded; } } // Vert mirrored or both if (mirrorType == 1 || (mirrorType == 2 && numTeams > 2)) { var mX = s.MapPosition.X; var mY = MirrorDimension(yDim, s.MapPosition.Y); var s2 = map.Sectors.FirstOrDefault(_ => _.MapPosition.X == mX && _.MapPosition.Y == mY); if (s2 != null) { s2.StartingSectorTeam = ++teamsAdded; } } } // Final Checks if (teamsAdded < numTeams || !map.IsValid()) { return(GenerateMirroredMap(size)); } return(map); }
private void UpdateFocussedBuildOrder() { // Focus on miners, outpost, random tech, garrison, refinery. Then main tech upgrades and bombers, then other random building and research. if (_game.Credits[_t] <= 100) { return; } if (_initTech == EInitialTargetTech.ChooseInSector) { var startingSector = _game.AllBases.First(_ => _.Team == Team && _.Type == EBaseType.Starbase).SectorId; var techRocks = _game.AllAsteroids.Where(_ => _.SectorId == startingSector && _.Active && !(_.Type == EAsteroidType.Generic || _.Type == EAsteroidType.Resource)).ToList(); var choice = StrategyGame.RandomItem(techRocks); switch (choice.Type) { case EAsteroidType.Carbon: _initTech = EInitialTargetTech.Supremacy; break; case EAsteroidType.Silicon: _initTech = EInitialTargetTech.Tactical; break; case EAsteroidType.Uranium: _initTech = EInitialTargetTech.Expansion; break; default: _initTech = EInitialTargetTech.Starbase; break; } _initTechName = Enum.GetName(typeof(EInitialTargetTech), _initTech); } var ourSectors = (from b in _game.AllBases where b.Active && b.Team == Team && b.CanLaunchShips() select b.SectorId).Distinct().ToList(); // If we have money, build resources if (_game.Credits[_t] > 1000) { var resourcesToBuild = (from c in _game.TechTree[_t].ResearchableItems(ETechType.Construction) where c.CanBuild() && c.AmountInvested < c.Cost && (c.Name.Contains("Miner") || c.Name.Contains("Resource")) select c).ToList(); TryToInvestInResources(resourcesToBuild, ourSectors); } // Expand & Build Randomly our focus tech: var basesToBuild = (from c in _game.TechTree[_t].ResearchableItems(ETechType.Construction) where c.CanBuild() && c.AmountInvested < c.Cost && (c.Name.Contains("Outpost") || c.Name.Contains("Starbase") || c.Name.Contains(_initTechName)) orderby c.Id descending select c).ToList(); TryToInvestInBases(basesToBuild, ourSectors); // Once we have built our tech, research it randomly along with bombers/drones if (!_flagBuiltFocusTech) { return; } var tech = (from t in _game.TechTree[_t].ResearchableItemsNot(ETechType.Construction) where t.CanBuild() && (int)t.Type == (int)_initTech && t.AmountInvested < t.Cost orderby t.Cost - t.AmountInvested, t.Id descending select t).Take(3).ToList(); var bbr = (from t in _game.TechTree[_t].TechItems where t.Active && !t.Completed && (t.Name.Contains("Bomber") || t.Name.Contains("Combat Drones")) select t).FirstOrDefault(); if (bbr != null) { tech.Add(bbr); } InvestInRandomTech(tech); // Once we are done with our focus, branch out! if (tech.Count() < 2) { _focusBuildOrder = false; } }
public BaseLaserWeapon(StrategyGame game, Color laserColor, float laserWidth, int fireTicks, int refireTicks, float range, float damage, Ship shooter, PointF offset) : base(game, fireTicks, refireTicks, range, damage, shooter, offset) { WeaponSound = ESounds.plasmamini1; LaserPen = new Pen(laserColor, laserWidth); }
public TechCarbonAsteroid(StrategyGame game, Random r, int width, int height, int sectorId) : base(game, StrategyGame.RockPicDir + Images[r.Next(0, Images.Length)], width, height, sectorId) { Type = EAsteroidType.Carbon; }
// Use this for initialization void Start() { _game = GameManager.Instance.ActiveStrategy as StrategyGame; _as = terminal.GetComponent <AudioSource>(); }
public Command(StrategyGame game) { this.Game = game; }
public TechTreeItem(StrategyGame game, Research ownerForm) { InitializeComponent(); _game = game; _researchForm = ownerForm; }
public void Setup() { _settings = GameSettings.Default(); _settings.TeamFactions[1] = AllegianceForms.Engine.Factions.Faction.Default(_settings); _game = new StrategyGame(); }
public void Setup() { var game = new StrategyGame(); _target = TechTree.LoadTechTree(game, StrategyGame.TechDataFile, 1); }
public HuntControlOrder(StrategyGame game, EShipType[] targetTypes) : base(game, -1) { _targetTypes = targetTypes; }
public MineOrder(StrategyGame game, int sectorId, PointF targetPosition, PointF offset) : base(game, sectorId, targetPosition, offset) { OrderPen.Color = Color.Gold; }
public BuildOrder(StrategyGame game, int sectorId, Point targetPosition, Point offset) : base(game, sectorId, targetPosition, offset) { OrderPen.Color = Color.Blue; }