/// <summary> /// Creates a structure /// </summary> /// <param name="type"></param> /// <param name="health"></param> /// <param name="xPos"></param> /// <param name="yPos"></param> /// <param name="owner"></param> /// <param name="commandCenter"></param> /// <returns></returns> public static IStructure CreateStructure(StructureTypes type, float xPos, float yPos, Player owner, CommandCenter commandCenter, int currentAreaID, IPlayerLocator pl) { IStructure s; switch (type) { case (StructureTypes.LaserTurret): s = new Turret(_localIDManager.PopFreeID(), xPos, yPos, owner, commandCenter, currentAreaID, pl); break; case (StructureTypes.Biodome): s = new Biodome(xPos, yPos, _localIDManager.PopFreeID(), owner, currentAreaID); break; case (StructureTypes.PowerPlant): s = new PowerPlant(xPos, yPos, _localIDManager.PopFreeID(), owner, currentAreaID); break; case (StructureTypes.Silo): s = new Silo(xPos, yPos, _localIDManager.PopFreeID(), owner, currentAreaID); break; default: throw new Exception("CreateStructure not implemented for structure type " + type.ToString()); } _galaxyRegistrationManager.RegisterObject(s); return(s); }
public IStructure(float maxhp, StructureTypes type, Teams team, Rect rectangle) : base(maxhp) { Type = type; Team = team; Rectangle = rectangle; }
public MessageStructurePlacementRequest(int requestingShipID, float posX, float posY, StructureTypes structureType) { PosX = posX; PosY = posY; StructureType = structureType; RequestingShipID = requestingShipID; }
/// <summary> /// headOrBase is a temporary hack used only for the turret /// </summary> /// <param name="structureType"></param> /// <param name="headOrBase"></param> /// <returns></returns> Texture2D GetTexture(StructureTypes structureType, bool headOrBase = false) { if (_textureManager == null) { return(null); } switch (structureType) { case StructureTypes.CommandCenter: return(_textureManager.CommandCenter); case StructureTypes.LaserTurret: if (headOrBase) { return(_textureManager.TurretHead); } else { return(_textureManager.TurretBase); } case StructureTypes.Biodome: return(_textureManager.Biodome); default: ConsoleManager.WriteLine("Error, texture type " + structureType + "not yet implemented in " + this, ConsoleMessageType.Error); return(null); } }
public IFloor BuildFloor(Range range, int floorNumber, StructureTypes structure, bool existingFloor, Tower tower) { IFloor floor; if (existingFloor) { floor = tower.Floors[floorNumber]; var oldRange = tower.Floors[floorNumber].Range; var newRange = floor.GetExtendedFloorRange(range); floor.ExtendRange(newRange); } else { switch (structure) { case StructureTypes.Floor: floor = new Floor(range); break; case StructureTypes.Lobby: floor = new Lobby(range.StartX); break; default: floor = null; break; } tower.AddFloor(floor); } return(floor); }
//private model //wpublic int [] ; public Structure(StructureTypes structureType, Model model, Cell cell, int cost, int prod, Player player) { Cell = cell; Cost = cost; Prod = prod; Player = player; }
public void Damage(float damageAmount) { if (StructureType == StructureTypes.Wall) //if the damage is being done to a wall... { if (damageAmount >= _currentDurability) { StructureType = StructureTypes.Floor; //either it breaks and it becomes a floor, _currentDurability = BaseDurability; } else { _currentDurability -= damageAmount; //or it takes damage. } } else if (StructureType == StructureTypes.Floor) //otherwise, if we're damaging a floor tile... { if (damageAmount >= _currentDurability) { StructureType = StructureTypes.Hole; //either it breaks and becomes a hole, } else { _currentDurability -= damageAmount; //or it takes damage and comes closer to becoming a hole. } } }
public StructureStatsChangedEventData(Teams team, StructureTypes type, float hp) : base(ServerCommand.StructureStatsChanged) { Team = team; Type = type; Health = hp; }
public int PopulationIncreasesWhenRoomIsAdded(StructureTypes structure) { var tower = new Tower(); var builder = new Builder(); var range = new Range(0, 6); builder.BuildRoom(structure, range, 1, false, tower); return tower.Population; }
public StructureData(StructureData d) { CurrentHealth = d.CurrentHealth; Id = d.Id; StructureType = d.StructureType; XPos = d.XPos; YPos = d.YPos; }
public int SubtractConstructionCostsReducesMoneyBalance(StructureTypes structure, bool isExistingFloor, int floorNumber, int startX, int endX) { var range = new Range(startX, endX); //var globalProperties = new GlobalProperties(); var gameLoop = new GameLoop(); var cost = gameLoop.PayForStructure(structure, isExistingFloor, floorNumber, range); //just room just floor or Room plus floor return(gameLoop.GlobalProperties.Money); }
public static int GetUnpaidSegments(Range unpaidRange, StructureTypes floorType) { int segments = unpaidRange.GetSegments(); if (floorType is StructureTypes.Lobby) { segments = segments / 4; } return(segments); }
void PrepareTower(Teams team, StructureTypes type) { AddRemarkableEvent(ServerCommand.TowerPreparingToShoot, (msg) => { bool left = team == Teams.Left; byte typ = (byte)type; msg.Write(left); msg.Write(typ); }); }
/// <summary> /// Returns a clone of the appropriate StructureStats object /// </summary> /// <param name="s"></param> /// <returns></returns> public static StructureStats GetStats(StructureTypes s) { if (_stats.ContainsKey(s)) { return(_stats[s].GetClone()); } else { ConsoleManager.WriteLine("Error: " + s.ToString() + " not found in StructureStatManager.GetStats.", ConsoleMessageType.Error); return(null); } }
public bool PayForStructure(StructureTypes structure, bool isExistingFloor, int floorNumber, Range range) { var cost = DetermineCost(structure, isExistingFloor, floorNumber, range); var sufficientBalance = IsBalanceSufficient(cost); if (!sufficientBalance) { return(false); } this.GlobalProperties.SubtractConstructionCosts(cost); return(true); }
/// <summary> /// Checks if the structure can be added according to various rules /// </summary> /// <param name="player"></param> /// <param name="buildingType"></param> /// <param name="xPos"></param> /// <param name="yPos"></param> /// <returns></returns> public override bool CanAddStructure(Player player, StructureTypes buildingType, float xPos, float yPos, out string resultMessage) { if ((player.CurrentAreaID != Id)) { resultMessage = "Player not in system."; return(false); } resultMessage = "Success"; return(true); }
public override void CreateStructure( float xPos, float yPos, StructureTypes structureType, float health, float constructionPoints, int ID, HashSet <int> teams) { Structure structure; switch (structureType) { case (StructureTypes.LaserTurret): /*Turret t = new PlanetTurret(_projectileManager, _textureManager, _shipManager, new Vector2(xPos, yPos), buildingType, _bus, _physicsManager, health, ID, 666); * structures.Add(ID, t); * t.potentialTargets = _potentialTargets; * t.isLocalSim = localSim; */ Turret t = new Turret(_projectileManager, _textureManager, _shipManager, _bus, _physicsManager.World, new Vector2(xPos, yPos), structureType, health, ID, 666, TurretTypes.Planet, teams); _teamManager.RegisterObject(t); _structures.Add(t); Turrets.Add(t); t.IsAlliedWithPlanetOwner = true; //True by default, may change later structure = t; break; case (StructureTypes.CommandCenter): { structure = new CommandCenter(_bus, _messageManager.SendEnterColonyRequest, _shipManager.IsEnterModeOn, _physicsManager.World, _textureManager, new Vector2(xPos, yPos), structureType, health, ID, teams); _teamManager.RegisterObject(structure); _structures.Add(structure); break; } default: structure = new Structure(_bus, _textureManager, xPos, yPos, structureType, health, ID, teams); // Need to move this _structures.Add(structure); structure.Body = BodyFactory.CreateCircle(_physicsManager.World, 1, 1, new StructureBodyDataObject(BodyTypes.Structure, ID, structure)); break; } _targetManager.RegisterObject(structure); }
public Tower(StructureTypes type, Teams team, Vec2 feetPos) : base(HEALTH, type, team, new Rect( feetPos.X - WIDTH / 2f, feetPos.Y - HEIGHT, WIDTH, HEIGHT)) { Debug.Assert(StructureHelper.IsTower(type)); TimeOfLastShot = 0f; Preparing = false; }
private int GetEndX(string[] inputs, int startX, StructureTypes structure) { int endX; if (inputs.Length > 3 && structure.Equals(StructureTypes.Floor)) { int.TryParse(inputs[3], out endX); } else { endX = startX + StructureInfo.AllTheInfo[structure].Segments; } return(endX); }
/// <summary> /// Creates a structure /// </summary> /// <param name="type"></param> /// <param name="xPos"></param> /// <param name="yPos"></param> /// <param name="owner"></param> /// <param name="commandCenter"></param> /// <param name="currentAreaID"></param> /// <param name="pl"></param> /// <param name="writeToDB">If true, must specify dbm</param> /// <param name="dbm">must be specified if writeToDB is true</param> /// <returns></returns> public static IStructure CreateStructure(StructureTypes type, float xPos, float yPos, Player owner, CommandCenter commandCenter, int currentAreaID, IPlayerLocator pl, bool writeToDB = false, IDatabaseManager dbm = null) { IStructure s; switch (type) { case (StructureTypes.LaserTurret): TurretTypes t = owner.GetArea().AreaType == AreaTypes.Planet ? TurretTypes.Planet : TurretTypes.Space; s = new Turret(_localIDManager.PopFreeID(), xPos, yPos, owner.Id, currentAreaID, t, pl); break; case (StructureTypes.Biodome): return(CreateBiodome(xPos, yPos, owner, currentAreaID)); case (StructureTypes.PowerPlant): s = new PowerPlant(xPos, yPos, _localIDManager.PopFreeID(), owner.Id, currentAreaID); break; case (StructureTypes.Silo): s = new Silo(xPos, yPos, _localIDManager.PopFreeID(), owner.Id, currentAreaID); break; case (StructureTypes.CommandCenter): return(CreateCommandCenter(xPos, yPos, owner, currentAreaID)); case (StructureTypes.Factory): s = new Factory(xPos, yPos, _localIDManager.PopFreeID(), owner.Id, currentAreaID); break; default: throw new Exception("CreateStructure not implemented for structure type " + type.ToString()); } _galaxyRegistrationManager.RegisterObject(s); if (writeToDB) { if (dbm == null) { throw new Exception("Error: must specify IDatabaseManager dbm if writeToDB is true."); } else { dbm.SaveAsync(s); } } return(s); }
private void BtnTetraView_Click(object sender, EventArgs e) { if (structType != StructureTypes.None) { SaveChanges(FindFoot(), ""); } structType = StructureTypes.Tetra; RemovePoints(); layoutControl3.Visible = true; ChangeBone = false; LoadBoneStructure LeftArrowStruct = new LoadBoneStructure(LeftInputBonesNormal, "Left", model1);; LeftArrowStruct.LoadBones(structType); BoneStructurePoints["Left"] = LeftArrowStruct.BoneSelectedPoints; DrawTetra("Left"); LoadBoneStructure RightArrowStruct = new LoadBoneStructure(RightInputBonesNormal, "Right", model1);; RightArrowStruct.LoadBones(structType); BoneStructurePoints["Right"] = RightArrowStruct.BoneSelectedPoints; DrawTetra("Right"); LoadBoneStructure LeftHighArrowStruct = new LoadBoneStructure(LeftInputBonesHigh, "LeftHigh", model1); LeftHighArrowStruct.LoadBones(structType); BoneStructurePoints["LeftHigh"] = LeftHighArrowStruct.BoneSelectedPoints; DrawTetra("LeftHigh"); LoadBoneStructure RightHighArrowStruct = new LoadBoneStructure(RightInputBonesHigh, "RightHigh", model1);; RightHighArrowStruct.LoadBones(structType); BoneStructurePoints["RightHigh"] = RightHighArrowStruct.BoneSelectedPoints; DrawTetra("RightHigh"); //var lefttetraview = new TetraViewClass(); //lefttetraview.RenderView(LeftInputBonesNormal, "Left", model1); //var righttetraview = new TetraViewClass(); //righttetraview.RenderView(RightInputBonesNormal, "Right", model1); //lefttetraview.ShowTetra(false); model1.Entities.Regen(); model1.ZoomFit(); model1.Invalidate(); }
public bool BuildStuff(int floorNumber, Range range, StructureTypes structure, bool existingFloor, Tower tower) { if (structure is StructureTypes.Lobby || structure is StructureTypes.Floor) { return(BuildFloor(range, floorNumber, structure, existingFloor, tower) != null); } if (structure is StructureTypes.StairCase) { return(BuildStairs(floorNumber, tower)); } if (structure is StructureTypes.Elevator) { return(BuildElevator(range.StartX, floorNumber, tower.Floors[floorNumber])); } return(BuildRoom(structure, range, floorNumber, existingFloor, tower)); }
private int CheckType(StructureTypes type) { int pointsNeeded = 2; switch (type) { case StructureTypes.Arrows: pointsNeeded = 2; break; case StructureTypes.Tetra: pointsNeeded = 1; break; } return(pointsNeeded); }
/// <summary> /// Merge with a local virtual table = need to check override keywords /// </summary> /// <param name="virtualTable">the virtual table to add</param> /// <param name="mixinName">the name of the mixin</param> /// <param name="log">the error logger</param> public void MergeWithLocalVirtualTable(MixinVirtualTable virtualTable, string mixinName, LoggerResult log) { foreach (var method in virtualTable.Methods) { var methodDecl = Methods.LastOrDefault(x => x.Method.IsSameSignature(method.Method)); if (methodDecl != null) { var isBaseMethod = method.Shader.BaseClasses.Any(x => x.Name.Text == methodDecl.Shader.Name.Text); if (isBaseMethod) { if (methodDecl.Method is MethodDefinition) { if (!method.Method.Qualifiers.Contains(StrideStorageQualifier.Override)) { log.Error(StrideMessageCode.ErrorMissingOverride, method.Method.Span, method.Method, mixinName); continue; } } else if (method.Method.Qualifiers.Contains(StrideStorageQualifier.Override)) { log.Error(StrideMessageCode.ErrorOverrideDeclaration, method.Method.Span, method.Method, mixinName); continue; } } Methods.Remove(methodDecl); } else { if (method.Method.Qualifiers.Contains(StrideStorageQualifier.Override)) { log.Error(StrideMessageCode.ErrorNoMethodToOverride, method.Method.Span, method.Method, mixinName); continue; } } Methods.Add(method); // TODO: handle declarations vs definitions } Variables.UnionWith(virtualTable.Variables.Where(x => !Variables.Contains(x))); StructureTypes.AddRange(virtualTable.StructureTypes.Where(x => !StructureTypes.Contains(x))); Typedefs.AddRange(virtualTable.Typedefs.Where(x => !Typedefs.Contains(x))); }
public bool IsDestructible(StructureTypes type) { switch (type) { case StructureTypes.TopTower: case StructureTypes.BottomTower: return true; // we can always destroy the first towers. case StructureTypes.BaseTower: return !TopTower.Alive || !BottomTower.Alive; // one of the first towers must be down case StructureTypes.Base: return !BaseTower.Alive; // base tower must be down default: throw new NotImplementedException("Structure " + type + " not implemented (IsDestructible)."); } }
private void BtnArrowView_Click(object sender, EventArgs e) { if (structType != StructureTypes.None) { SaveChanges(FindFoot(), ""); } structType = StructureTypes.Arrows; RemovePoints(); checkChangeBone.Enabled = false; LoadBoneStructure LeftArrowStruct = new LoadBoneStructure(LeftInputBonesNormal, "Left", model1);; LeftArrowStruct.LoadBones(structType); BoneStructurePoints["Left"] = LeftArrowStruct.BoneSelectedPoints; DrawArrows("Left"); LoadBoneStructure RightArrowStruct = new LoadBoneStructure(RightInputBonesNormal, "Right", model1);; RightArrowStruct.LoadBones(structType); BoneStructurePoints["Right"] = RightArrowStruct.BoneSelectedPoints; DrawArrows("Right"); LoadBoneStructure LeftHighArrowStruct = new LoadBoneStructure(LeftInputBonesHigh, "LeftHigh", model1); LeftHighArrowStruct.LoadBones(structType); BoneStructurePoints["LeftHigh"] = LeftHighArrowStruct.BoneSelectedPoints; DrawArrows("LeftHigh"); LoadBoneStructure RightHighArrowStruct = new LoadBoneStructure(RightInputBonesHigh, "RightHigh", model1);; RightHighArrowStruct.LoadBones(structType); BoneStructurePoints["RightHigh"] = RightHighArrowStruct.BoneSelectedPoints; DrawArrows("RightHigh"); //ArrowViewClass leftarrowview = new ArrowViewClass(); //leftarrowview.RenderView(LeftInputBonesNormal, "Left", model1); //ArrowViewClass rightarrowview = new ArrowViewClass(); //rightarrowview.RenderView(RightInputBonesNormal, "Right", model1); //leftarrowview.ShowPoints(false); model1.Entities.Regen(); model1.ZoomFit(); model1.Invalidate(); }
public bool BuildRoom(StructureTypes structure, Range range, int floorNumber, bool existingFloor, Tower tower) { //But, . . .only Floors can have rooms IFloor floor; var room = GetRoom(structure, range.StartX, floorNumber); floor = BuildFloor(range, floorNumber, StructureTypes.Floor, existingFloor, tower); ((Floor)floor).AddRoom(room); tower.UpdatePopulation(room.Population); //needs to be evaluated if stairs are created also. room.SetOccupancy(tower, floorNumber); return(true); }
/// <summary> /// Checks if the structure can be added according to various rules /// </summary> /// <param name="player"></param> /// <param name="buildingType"></param> /// <param name="xPos"></param> /// <param name="yPos"></param> /// <returns></returns> public override bool CanAddStructure(Player player, StructureTypes buildingType, float xPos, float yPos, out string resultMessage) { if (player.CurrentAreaID != Id) { resultMessage = "Player is not on the planet."; return(false); } else if (!player.ColonizedPlanetIDs.Contains(Id) || (IsColonized && !player.GetTeamIDs().Overlaps(GetOwner().GetTeamIDs()))) { resultMessage = "Cannot place structures on unallied planets."; return(false); } else { resultMessage = "Success"; return(true); } }
public int CollectRentForCondoDoesNotAddToProfit(StructureTypes structure) { var tower = new Tower(); var builder = new Builder(); var range = new Range(0, 6); var time = new Time(0, 0, Day.WeekdayTwo, 0, 0); tower.AddFloor(new Lobby(0)); tower.Floors[0].ExtendRange(new Range(0, 12)); tower.AddFloor(new Floor(range)); builder.BuildRoom(structure, range, 1, true, tower); builder.BuildStairs(0, tower); tower.CollectRent(time); return tower.Floors[1].Ledger.TotalProfit; }
public override void CreateStructure(float xPos, float yPos, StructureTypes buildingType, float health, float constructionPoints, int ID, HashSet <int> teams) { switch (buildingType) { case (StructureTypes.LaserTurret): Turret t = new Turret(_projectileManager, _textureManager, _shipManager, _bus, _physicsManager.World, new Vector2(xPos, yPos), buildingType, health, ID, 666, TurretTypes.Space, teams); _teamManager.RegisterObject(t); _structures.Add(t); t.Teams = teams; break; default: _structures.Add(new Structure(_bus, _textureManager, xPos, yPos, buildingType, health, ID, teams)); break; } }
public bool IsDestructible(StructureTypes type) { switch (type) { case StructureTypes.TopTower: case StructureTypes.BottomTower: return(true); // we can always destroy the first towers. case StructureTypes.BaseTower: return(!TopTower.Alive || !BottomTower.Alive); // one of the first towers must be down case StructureTypes.Base: return(!BaseTower.Alive); // base tower must be down default: throw new NotImplementedException("Structure " + type + " not implemented (IsDestructible)."); } }
public StructureDestroyedEventData(Teams team, StructureTypes type) : base(ServerCommand.StructureDestroyed) { Team = team; Type = type; }
public static bool IsTower(StructureTypes type) { return Utilities.MakeList(StructureTypes.BaseTower, StructureTypes.BottomTower, StructureTypes.TopTower).Contains(type); }
public TowerPreparingToShootEventData(Teams team, StructureTypes type) : base(ServerCommand.TowerPreparingToShoot) { Team = team; Type = type; }
DrawableStructure GetStructure(Teams team, StructureTypes type) { Debug.Assert(Structures.Exists(s => s.Structure.Team == team && s.Structure.Type == type)); return Structures.Exists(s => s.Structure.Team == team && s.Structure.Type == type) ? Structures.Find(s => s.Structure.Team == team && s.Structure.Type == type) : null; }