public void Setup() { _heater = Substitute.For <IHeater>(); _tempsensor = Substitute.For <ITempSensor>(); _uut = new Ecs(25, _tempsensor, _heater); //Ecs_ctor_inject(); }
public void process(Ecs ecs, float delta, params dynamic[] args) { if (args[0] == "update") { GameMap gameMap = (GameMap)GetNode("/root/scene/gamespace/GameMap"); if (gameMap.state == "player_at" && this.inputActionQueue.Count != 0) { string action = this.inputActionQueue.Dequeue(); switch (action) { case "player_move_west": PlayerMove pm = (PlayerMove)GetNode("/root/scene/gamespace/actions/PlayerMove"); pm.execute("west"); break; case "player_move_east": pm = (PlayerMove)GetNode("/root/scene/gamespace/actions/PlayerMove"); pm.execute("east"); break; case "player_move_north": pm = (PlayerMove)GetNode("/root/scene/gamespace/actions/PlayerMove"); pm.execute("north"); break; case "player_move_south": pm = (PlayerMove)GetNode("/root/scene/gamespace/actions/PlayerMove"); pm.execute("south"); break; case "player_move_northwest": pm = (PlayerMove)GetNode("/root/scene/gamespace/actions/PlayerMove"); pm.execute("northwest"); break; case "player_move_northeast": pm = (PlayerMove)GetNode("/root/scene/gamespace/actions/PlayerMove"); pm.execute("northeast"); break; case "player_move_southwest": pm = (PlayerMove)GetNode("/root/scene/gamespace/actions/PlayerMove"); pm.execute("southwest"); break; case "player_move_southeast": pm = (PlayerMove)GetNode("/root/scene/gamespace/actions/PlayerMove"); pm.execute("southeast"); break; case "player_wait": default: return; } } else { } } }
public void Setup() { uutFakeTempSensor = new FakeTempSensor(); uutFakeHeater = new FakeHeater(); uutFakeWindow = new FakeWindow(); uut = new Ecs(15, 25, uutFakeTempSensor, uutFakeHeater, uutFakeWindow); }
public Ecs SelectEcs(string owner) { Ecs ecs = (from c in db.Ecs where c.Owner == owner select c).First(); return(ecs); }
public void Ecs_Connections_AreValid() { var ecs = new Ecs(); Assert.NotNull(ecs.Connections.FirstOrDefault(c => c is MemoryMap)); Assert.NotNull(ecs.Connections.FirstOrDefault(c => c is CartridgePort)); Assert.Equal(2, ecs.Connections.Count()); }
public void Setup() { uutHeater = Substitute.For <IHeater>(); uutTempSensor = Substitute.For <ITempSensor>(); uutWindow = Substitute.For <IWindow>(); uut = new Ecs(25, 30, uutTempSensor, uutHeater, uutWindow); }
public void UpdateStatus(string status, string owner) { Ecs ecs = (from c in db.Ecs where c.Owner == owner select c).First(); ecs.Status = status; db.SubmitChanges(); }
public void Insert(string owner) { Ecs ecs = new Ecs { Owner = owner, }; db.Ecs.InsertOnSubmit(ecs); db.SubmitChanges(); }
protected void Page_Load(object sender, EventArgs e) { if (Session["CustomerName"] == null) //用户未登录 { Response.Redirect("~/Login.aspx"); } string name = Session["CustomerName"].ToString(); Ecs ecs = ecsService.SelectEcs(name); status = ecs.Status; }
public Entity CreateLevel(TiledMap level) { var entity = Ecs.CreateEntity(); entity.Attach <TiledMapComponent>() .Map = level; entity.Attach <TiledMapRendererComponent>() .Renderer = new TiledMapRenderer(Game.GraphicsDevice); return(entity); }
public void UpdateEcs(string user, string password, string host, string url, string owner) { Ecs ecs = (from c in db.Ecs where c.Owner == owner select c).First(); ecs.User = user; ecs.Password = password; ecs.Host = host; ecs.Url = url; db.SubmitChanges(); }
public void Ecs_IRomCompatibleWithEcsRom_IsTrue() { var ecs = new Ecs(); var programInformationTable = ProgramInformationTable.Initialize(Enumerable.Empty <ProgramInformationTableDescriptor>().ToArray()); var mindStrikeProgramId = new ProgramIdentifier(0x9D57498F); var mindStrikeInfo = programInformationTable.FindProgram(mindStrikeProgramId); Assert.NotNull(mindStrikeInfo); var mindStrikeDescription = new ProgramDescription(mindStrikeProgramId.DataCrc, null, mindStrikeInfo); Assert.True(ecs.IsRomCompatible(mindStrikeDescription)); }
public bool IsNameExist(string owner) { Ecs ecs = (from c in db.Ecs where c.Owner == owner select c).FirstOrDefault(); if (ecs != null) { return(true); } else { return(false); } }
protected void Page_Load(object sender, EventArgs e) { if (Session["CustomerName"] == null) //用户未登录 { Response.Redirect("~/Login.aspx"); } name = Session["CustomerName"].ToString(); if (!ecsService.IsNameExist(name)) { ecsService.Insert(name); } Ecs ecs = ecsService.SelectEcs(name); host = ecs.Host; username = ecs.User; password = ecs.Password; url = ecs.Url; }
public Entity CreatePlayer(Vector2 position) { var entity = Ecs.CreateEntity(); entity.Attach <TransformComponent>() .Size = alienGreen_stand.Bounds.Size.ToVector2(); entity.Attach <SpriteComponent>() .Sprite = new Sprite(alienGreen_stand); entity.Attach <PlayerComponent>(); entity.Attach <RigidbodyComponent>(); entity.Attach <PlayerController>(); entity.Attach <SpriteBatchComponent>() .SpriteBatch = Ecs.Game.Services.GetService <SpriteBatch>(); return(entity); }
public override Action Update() { var locationSystem = this.Ecs.GetSystem <HasLocation>() as LocationSystem; if (locationSystem == null) { throw new InvalidCastException("Location system couldn't be retrieved and cast"); } if ( locationSystem.EntitiesAtSameLocation(this.Entity) .Any(e => this.Ecs.GetComponent <IsActor>(e).Type == this.type)) { return(() => { if (Ecs.HasEntity(this.Entity)) { this.Ecs.RemoveEntity(this.Entity); // Blarg ded } }); } return(null); }
public void Ecs_IRomCompatibleWithNull_ThrowsNullReferenceException() { var ecs = new Ecs(); Assert.Throws <NullReferenceException>(() => ecs.IsRomCompatible(null)); }
public void Move(Vector newPosition) { Ecs.GetSystem <Area>().Move(this, newPosition); }
public void process(Ecs ecs, float delta, params dynamic[] args) { if (args[0] == "render") { if (args[1] == "local") { LocalMap map = ecs.loadedMaps[(int)NeighbourMapDirection.center]; if (map.dirty) { TileMap gameMap = (TileMap)GetNode("/root/scene/gamespace/GameMap"); var tileSet = gameMap.TileSet; map.dirty = false; List <string> tags = new List <string>(); tags.Add("Camera2D"); tags.Add("LocalCamera"); tags.Add("ViewPort"); List <Entity> entities = ecs.getEntities(tags); var camera = entities[0]; ViewPort viewPort = camera.getComponent <ViewPort>(); int w = viewPort.x + viewPort.w; int h = viewPort.y + viewPort.h; List <string> playerTags = new List <string>(); playerTags.Add("Player"); List <Entity> playerList = ecs.getEntities(playerTags); Player player = (Player)playerList[0]; LightRadius lightRadius = player.getComponent <LightRadius>(); WorldPosition position = player.getComponent <WorldPosition>(); map.ComputeFov(position.localMapX, position.localMapY, lightRadius.radius, true); foreach (Cell cell in map.GetAllCells()) { if (cell.IsInFov) { map.SetCellProperties(cell.X, cell.Y, cell.IsTransparent, cell.IsWalkable, true); } } //NOTE: This is a hack to get the camera to display in the top left of the screen. //Consider setting this in the camera class instead?? int x = 0; int y = 0; for (int i = viewPort.x; i < (viewPort.x + viewPort.w); i++) { for (int j = viewPort.y; j < (viewPort.y + viewPort.h); j++) { if (i < 0 || j < 0 || i > map.Width - 1 || j > map.Height - 1) { gameMap.SetCell(x, y, -1); } else { KeyPoint p = new KeyPoint(i, j); KeyPoint p2 = new KeyPoint(i, j - 1); KeyPoint p3 = new KeyPoint(i, j + 1); int hc1 = p.GetHashCode(); int hc2 = p2.GetHashCode(); int hc3 = p3.GetHashCode(); Vicinity topNeighbour; Vicinity bottomNeighbour; bool hasTopNeighbour = false; bool hasBottomNeighbour = false; if (j >= 1) { hasTopNeighbour = true; if (!map.vicinities.ContainsKey(hc2)) { GD.Print(p2.X); GD.Print(p2.Y); } topNeighbour = map.vicinities[hc2]; } else { topNeighbour = map.vicinities[hc1]; } if (j <= 126) { hasBottomNeighbour = true; bottomNeighbour = map.vicinities[hc3]; } else { bottomNeighbour = map.vicinities[hc1]; } Vicinity vicinity = map.vicinities[hc1]; string tileID = vicinity.getValue(); string tileColor = vicinity.getColor(); if (hasTopNeighbour && topNeighbour.getValue() == vicinity.getValue() && !hasBottomNeighbour) { tileID = vicinity.getTerminalValue(); } else if (hasTopNeighbour && topNeighbour.getValue() == vicinity.getValue() && hasBottomNeighbour && bottomNeighbour.getValue() != vicinity.getValue()) { tileID = vicinity.getTerminalValue(); } else if (hasTopNeighbour && hasBottomNeighbour && topNeighbour.getValue() != vicinity.getValue() && bottomNeighbour.getValue() != vicinity.getValue()) { tileID = vicinity.getTerminalValue(); } else { tileID = vicinity.getValue(); } Cell cell = (Cell)map.GetCell(i, j); if (cell.IsExplored && cell.IsInFov) { string tileName = tileID + "_" + tileColor; int id = tileSet.FindTileByName(tileName); gameMap.SetCell(x, y, id); } else if (cell.IsExplored) { string tileName = tileID + "_" + "101024"; int id = tileSet.FindTileByName(tileName); gameMap.SetCell(x, y, id); } else { gameMap.SetCell(x, y, -1); } } y += 1; } x += 1; y = 0; } } } } }
public ContainerSlice ContainerSlice <T>() where T : PrototypeContainer => new ContainerSlice( this, Ecs.GetContainer <T>().Subjects.ToArray());
public void Ecs_Name_IsCorrect() { var ecs = new Ecs(); Assert.Equal("ECS", ecs.Name); }
public void postInit(Ecs ecs) { }
public override string InfoString() { return(base.InfoString() + "\nCountry\t" + Country + "\nEcs\t" + Ecs.ToString()); }
public void process(Ecs ecs, float delta, params dynamic[] args) { if (args[0] == "render") { return; } else { var gameMap = (GameMap)GetNode("/root/scene/gamespace/GameMap"); if (gameMap.state == "init") { gameMap.state = "ct_await"; } if (gameMap.state != "ct_await" && gameMap.state != "player_at" && gameMap.state != "npc_at") { this.cache.Clear(); return; } if (cache.Count == 0) { bool AT = false; while (!AT) { foreach (Entity entity in ecs.entities) { if (entity.hasTag("Actor")) { Actor actor = entity.getComponent <Actor>(); actor.ct += actor.speed; } } foreach (Entity entity in ecs.entities) { if (entity.hasTag("Actor")) { Actor actor = entity.getComponent <Actor>(); if (actor.ct >= resolutionThreshold) { this.cache.Add(entity); AT = true; } } } } if (cache.Count > 0) { this.cache.Sort((self, other) => self.getComponent <Actor>().ct.CompareTo(other.getComponent <Actor>().ct)); this.cache.Reverse(); Entity entity = this.cache[0]; this.cache.RemoveAt(0); gameMap.AT = entity; Actor actor = entity.getComponent <Actor>(); if (actor.isPlayerCharacter) { gameMap.state = "player_at"; return; } else { gameMap.state = "npc_at"; return; } } } else if (gameMap.state == "ct_await") { Entity entity = this.cache[0]; this.cache.RemoveAt(0); gameMap.AT = entity; Actor actor = entity.getComponent <Actor>(); if (actor.isPlayerCharacter) { gameMap.state = "player_at"; } else { gameMap.state = "npc_at"; } } } }