public void TestInitialize() { this.mockRepository = new MockRepository(MockBehavior.Strict); var gameArena = new GameArena(1); this.mockLogicFacade = this.mockRepository.Create <LogicFacade>(gameArena, new Lobby(gameArena)); }
public void ShouldSetPropertiesToTrue() { GameArena arena = new GameArena(0); arena.StartGame(); Assert.AreEqual(true, arena.isStarted); Assert.AreEqual(true, arena.UpdateRequired); }
void Awake() { m_ActionLagBuffer = GetComponent <ActionLagBuffer>(); m_AIRobotSettings = FindObjectOfType <AIRobotSettings>(); actionCounterMax = GetComponent <DecisionRequester>().DecisionPeriod; m_ArenaGO = transform.parent.gameObject; m_GameArena = m_ArenaGO.GetComponent <GameArena>(); }
public void ShouldInitialize() { //Arrange GameArena arena = new GameArena(0); //Assert Assert.IsNotNull(arena.Players); Assert.IsNotNull(arena.grid); Assert.IsNotNull(arena.walls); }
public void Should_ReturnTrue_When_Kick(Explosive.KickDirection dir) { //Arrange GameArena arena = new GameArena(0); Explosive bomb = new Explosive(1, 1); // Act arena.gameObjects.Add(bomb); //Assert Assert.IsTrue(arena.KickBomb(bomb.GetCords(), dir)); }
public void Should_ReturnFalse_When_Kick(int x, int y, Explosive.KickDirection dir) { //Arrange GameArena arena = new GameArena(0); Explosive bomb = new Explosive(x, y); // Act arena.gameObjects.Add(bomb); //Assert Assert.IsFalse(arena.KickBomb(bomb.GetCords(), dir)); }
public void ShouldSetUpdate() { var arena = new GameArena(0); var logic = new ArenaLogic(arena); arena.isStarted = true; if (arena.isStarted) { arena.UpdateRequired = false; } Assert.AreEqual(false, arena.UpdateRequired); }
public void ShouldAddGameObject() { //Arrange Explosive gameObject = new Explosive(1, 1); List <IGameObject> gameObjectsExpected = new List <IGameObject>(); gameObjectsExpected.Add(gameObject); // Act GameArena arena = new GameArena(0); arena.gameObjects.Add(gameObject); //Assert CollectionAssert.AreEqual(gameObjectsExpected, arena.gameObjects); }
/// <summary> /// Called when a generic message has arrived. Notifies game arena of message /// </summary> /// <param name="ownerId">The original broadcaster of the message</param> /// <param name="payload">The message object</param> /// <param name="time">The time the message was sent, used for projecting the state to current time.</param> private void ApplyGenericMessage(ulong id, object payload, double time) { log?.Debug($"Received generic message from client {INetworkEntityExtensions.UnpackClientId(id)}"); if (payload == null) { var msg = "Bad or missing payload for generic message."; log?.Error(msg); throw new RedGrinException(msg); } GameArena?.HandleGenericMessage(id, payload, time); BroadcastIfServer(id, payload, NetworkMessageType.Generic); }
public void Execute_StateUnderTest_ExpectedBehavior() { // Arrange var generalCommand = this.CreateGeneralCommand(); var arena = new GameArena(1); generalCommand.Receiver = this.Receiver.Object; generalCommand.Author = new Player(User); this.Receiver.Setup(x => x.Action(It.IsAny <GeneralCommand>())); // Act generalCommand.Execute(); // Assert this.Receiver.Verify(x => x.Action(generalCommand), Times.Once); }
public void Execute_StateUnderTest_ExpectedBehavior() { // Arrange var arenaCommand = this.CreateArenaCommand(); var arena = new GameArena(1); arenaCommand.Receiver = this.Receiver.Object; arenaCommand.Author = new Player(new User(1, "user")); this.Receiver.Setup(x => x.Action(It.IsAny <ArenaCommand>())); // Act arenaCommand.Execute(); this.Receiver.Verify(x => x.Action(arenaCommand), Times.Once); }
/// <summary> /// Called when a Destroy message has arrived, destroys an entity. /// </summary> /// <param name="entityId">The unique ID of the entity to be destroyed</param> private void DestroyEntity(ulong id) { INetworkEntity target = entities.Where(e => e.Id == id).SingleOrDefault(); if (target != null) { log.Debug($"Destroying entity {id}"); BroadcastIfServer(target.Id, null, NetworkMessageType.Destroy); entities.Remove(target); GameArena?.HandleDestroyEntity(target); } else { log.Debug($"Couldn't find entity marked for destruction: {id}"); } }
public void ShouldRemoveGameObjectAt_When_Not_Pickable() { //Arrange GameArena arena = new GameArena(0); List <IGameObject> gameObjectsExpected = new List <IGameObject>(); GameObject obj = new GameObject(new Coordinates(0, 1)); Pickable powerup = new BombFireDecrease(new GameObject(new Coordinates(2, 2))); // Act gameObjectsExpected.Add(powerup); arena.gameObjects.Add(obj); arena.gameObjects.Add(powerup); arena.RemoveGameObjectAt(obj.GetCords().X, obj.GetCords().Y); //Assert CollectionAssert.AreNotEqual(arena.gameObjects, gameObjectsExpected); }
/// <summary> /// Called when a Create message has arrived, gets an entity from the game screen. /// </summary> /// <param name="ownerId">The NetworkId of the peer that controls the new entity.</param> /// <param name="entityId">The unique identifier for the entity.</param> /// <param name="payload">The object that will be used to apply the entity's starting state.</param> /// <param name="time">The time the message was sent, used for projecting the state to current time.</param> private void CreateEntity(ulong id, object payload, double time) { // check entity with ID already exists INetworkEntity targetEntity = entities.Where(e => e.Id == id).SingleOrDefault(); if (targetEntity == null) { targetEntity = GameArena?.HandleCreateEntity(id, payload); // force correct unique ID targetEntity.Id = id; } targetEntity.UpdateFromState(payload, time, false); entities.Add(targetEntity); BroadcastIfServer(id, payload, NetworkMessageType.Create); }
public void ShouldRemoveGameObjectAt_When_Pickable() { //Arrange GameArena arena = new GameArena(0); List <IGameObject> gameObjectsExpected = new List <IGameObject>(); Explosive bomb = new Explosive(1, 1); Pickable powerup = new BombFireDecrease(new GameObject(new Coordinates(2, 2))); // Act gameObjectsExpected.Add(bomb); arena.gameObjects.Add(bomb); arena.gameObjects.Add(powerup); arena.RemoveGameObjectAt(powerup.GetCords().X, powerup.GetCords().Y); //Assert CollectionAssert.AreEqual(arena.gameObjects, gameObjectsExpected); }
public void ShouldSetWallsGrid() { //Arrange GameArena arena = new GameArena(0); // Act arena.UpdateGrid(); //Assert for (int i = 0; i < 13; i++) { for (int j = 0; j < 13; j++) { if (arena.grid.GetGrid()[i, j].Count > 0) { Assert.IsTrue(arena.grid.GetGrid()[i, j].Contains(Walls.walls[i, j])); } } } }
public void ShouldReturnOnlyDeadPlayers() { //Arrange List <int> expectedDeads = new List <int>(); GameArena arena = new GameArena(0); for (int i = 0; i < 4; i++) { Player pl = new Player(new User(i)); pl.Alive = Convert.ToBoolean(i % 2); arena.Players.Add(pl); // Act if (!pl.Alive) { expectedDeads.Add(pl.User.Id); } } //Assert CollectionAssert.AreEqual(expectedDeads, arena.DeadPlayers()); }
public ArenaLogic(GameArena arena) { this.arena = arena; }
public string blueGoalTag; //will be used to check if collided with blue goal void Awake() { arena = transform.parent.GetComponent <GameArena>(); }
public LogicFacade(GameArena arena, Lobby lobby) { this.logicBase = new LogicBase(this); this.arenaLogic = new ArenaLogic(arena); this.generalLogic = new GeneralLogic(lobby); }