public void Test_ShouldSpawnUnit_WhenExecuteInvoked(int x, int y) { // Arrange Mock <EntitySpawner> spawner = new Mock <EntitySpawner>(MockBehavior.Loose, new object[] { gameController }); spawner.Setup(entitySpawner => entitySpawner.SpawnUnit(It.IsAny <UnitController>(), It.IsAny <Coords>())).Verifiable(); gameController.Spawner = spawner.Object; Coords coords = new Coords() { x = x, y = y }; UnitDef unitDef = Mock.Of <UnitDef>(); Mock <SpawnActionDef> actionDef = new Mock <SpawnActionDef>(new object[] { (uint)10, "image", unitDef }); actionDef.SetupGet(def => def.SpawnableDef).Returns(() => unitDef); Mock <ITargetable> target = new Mock <ITargetable>(); target.Setup(targetable => targetable.FloatCoords).Returns(() => (FloatCoords)coords); SpawnAction spawnAction = new SpawnAction(actionDef.Object, gameController, factionController); // Act spawnAction.Execute(target.Object); // Assert spawner.VerifyAll(); }
static void MarkBuildTree(UnitDef builder) { builder.IsInBuildTree = true; foreach (var unit in builder.BuildOptions) { if (!unit.IsInBuildTree) { unit.Parent = builder; MarkBuildTree(unit); } } }
private void btnTest_Click(object sender, EventArgs e) { try { //Graphics gg = this.CreateGraphics(); //gg.GetHdc(); //gg.DrawLine(new Pen(Color.Red), 0, 0, 900, 900); //gg.DrawArc(new Pen(Color.Red), 500, 500, 50, 50, 0, 90); //gg.ReleaseHdc(); Graphics g = this.CreateGraphics(); SVGRenderer.getInstance().renderSVGPathToGraphics(g); String symbolID = "SFZP------*****"; String spaceStation = "SFPPT-----*****"; String ambush = "GFGPSLA---*****"; String checkPoint = "GFGPGPPK--****X"; UnitDef ud = UnitDefTable.getInstance().getUnitDef(SymbolUtilities.getBasicSymbolID(symbolID)); Console.WriteLine(ud.getDescription()); SymbolDef sd = SymbolDefTable.getInstance().getSymbolDef(SymbolUtilities.getBasicSymbolID(ambush), 1); Console.WriteLine(sd.getDescription()); int mapping = SinglePointLookup.getInstance().getCharCodeFromSymbol(checkPoint); Console.WriteLine(mapping.ToString()); UnitFontLookupInfo ufli = UnitFontLookup.getInstance().getLookupInfo(spaceStation); Console.WriteLine(ufli.getMapping1(spaceStation).ToString()); SinglePointRenderer spr = SinglePointRenderer.getInstance(); //Bitmap tempBMP = spr.DrawTest(); //tempBMP.Save("C:\\test.bmp", System.Drawing.Imaging.ImageFormat.Bmp); //MilStdBMP msb = spr.RenderSymbol(spaceStation, null, null); //msb.getBitmap().Save("C:\\test.png", System.Drawing.Imaging.ImageFormat.Png); //Graphics g = Graphics.FromHwnd(this.Handle); //Graphics g = this.CreateGraphics(); float x = this.Width / 2.0f; float y = this.Height / 2.0f; //g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.Bilinear; //g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; //g.DrawImageUnscaled(tempBMP, (int)x, (int)y); //g.Flush(); //g.Dispose(); // g.DrawImage(spr.DrawTest(), x, y); } catch (Exception exc) { Console.WriteLine(exc.Message); Console.WriteLine(exc.StackTrace); } }
public bool PrerequisitesMet(PlayerId playerId, UnitDef unitDef) { world.ValidatePlayer(playerId); if (unitDef.PlayerTypeRestriction != playerRepository.GetPlayerType(playerId)) { return(false); } foreach (var prereq in unitDef.Prerequisites) { if (!assetRepository.HasAsset(playerId, prereq)) { return(false); } } return(true); }
// Get the Def from the given unit public static UnitDef GetUnitDef(int unitId) { UnitDef returnedUnitDef = new UnitDef(); string query = $"SELECT * FROM UnitDef WHERE Id=@i"; using (SqliteCommand cmd = new SqliteCommand(query, DBConn)) { cmd.Parameters.Add(new SqliteParameter("@i", unitId)); using (SqliteDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { returnedUnitDef.Speed = float.Parse(reader["Speed"].ToString()); returnedUnitDef.Image = reader["Image"].ToString(); returnedUnitDef.Width = float.Parse(reader["Width"].ToString()); returnedUnitDef.Height = float.Parse(reader["Height"].ToString()); returnedUnitDef.Upkeep = float.Parse(reader["Upkeep"].ToString()); returnedUnitDef.PurchaseCost = float.Parse(reader["Cost"].ToString()); returnedUnitDef.ViewRange = int.Parse(reader["ViewRange"].ToString()); returnedUnitDef.TrainingTime = uint.Parse(reader["TrainingTime"].ToString()); // This is for the different defs not implemented yet /*returnedUnitDef.BattleDef.AttackModifier = double.Parse(reader["BattleDef.AttackModifier"].ToString()); * returnedUnitDef.BattleDef.DefenseModifier = double.Parse(reader["BattleDef.DefenseModifier"].ToString()); * returnedUnitDef.BattleDef.Accuracy = double.Parse(reader["BattleDef.Accuracy"].ToString()); * returnedUnitDef.BattleDef.DodgeChance = double.Parse(reader["BattleDef.DodgeChance"].ToString()); * returnedUnitDef.BattleDef.RangeModifier = double.Parse(reader["BattleDef.RangeModifier"].ToString()); * * returnedUnitDef.HPDef.CurrentHP = int.Parse(reader["HPDef.CurrentHP"].ToString()); * returnedUnitDef.HPDef.MaxHP = int.Parse(reader["HPDef.MaxHP"].ToString()); * * returnedUnitDef.LevelXPDef.Level = int.Parse(reader["LevelXPDef.Level"].ToString()); * returnedUnitDef.LevelXPDef.XP = int.Parse(reader["LevelXPDef.XP"].ToString()); * returnedUnitDef.LevelXPDef.XPNeed = int.Parse(reader["LevelXPDef.XPNeed"].ToString());*/ } } } return(returnedUnitDef); }
bool IsValid(UnitDef unit) { if (morphedUnitNames.Contains(unit.Name)) return true; if (unit.Parent != null) return true; return false; }
public Unit(UnitDef unitDef, int worldX, int worldY, string state) : base(unitDef, new(worldX, worldY), SnowballFightGame.UnitLayer, state: state)
/** * * */ private void Init() { try { SymbolDefTable sdTable = SymbolDefTable.getInstance(); Dictionary <String, SymbolDef> symbolDefs = sdTable.getAllSymbolDefs(); ICollection <SymbolDef> vc = symbolDefs.Values; IEnumerator <SymbolDef> enumerator = vc.GetEnumerator(); SymbolDef sdTemp = null; UnitDef udTemp = null; String item = null; while (enumerator.MoveNext()) { sdTemp = enumerator.Current; item = sdTemp.getDescription() + ":" + sdTemp.getBasicSymbolId(); if (sdTemp.getDrawCategory() != 0)//0 means category, not drawable { lbTGs.Items.Add(item); } } lbTGs.Sorted = true; //////////////////////////////////////////////////////////////////////// UnitDefTable udTable = UnitDefTable.getInstance(); Dictionary <String, UnitDef> unitDefs = udTable.GetAllUnitDefs(); ICollection <UnitDef> c = unitDefs.Values; IEnumerator <UnitDef> ude = c.GetEnumerator(); //SymbolDef temp = null; //String item = null; while (ude.MoveNext()) { udTemp = ude.Current; item = udTemp.getDescription() + ":" + udTemp.getBasicSymbolId(); lbFEs.Items.Add(item); } lbFEs.Sorted = true; ///////////////////////////////////////////////////////////////////////// cbAffiliation.SelectedIndex = 0; cbStatus.SelectedIndex = 1; cbModifiers.SelectedIndex = 0; cbSize.SelectedIndex = 0; cbOutlineType.SelectedIndex = 0; cbSpeedTestType.SelectedIndex = 1; cbDoubleBuffer.CheckState = CheckState.Checked; //RENDERER SETTINGS////////////////////////////////////////////////////// RendererSettings RS = RendererSettings.getInstance(); RS.setTextBackgroundMethod(RendererSettings.TextBackgroundMethod_OUTLINE_QUICK); //RS.setTextBackgroundMethod(RendererSettings.TextBackgroundMethod_OUTLINE); //RS.setTextBackgroundMethod(RendererSettings.TextBackgroundMethod_NONE); //RS.setTextBackgroundMethod(RendererSettings.TextBackgroundMethod_COLORFILL); } catch (Exception exc) { Console.WriteLine(exc.Message); Console.WriteLine(exc.StackTrace); } }
public Squad(int sumSpeedUnit, int sumSpeedRush, int sumSpeedDef) { unitSpeed = new UnitSpeed(sumSpeedUnit); unitRush = new UnitRush(sumSpeedRush); unitDef = new UnitDef(sumSpeedDef); }
public Unit_Model(UnitDef def) { Def = def; Selected = false; }