public void Should_Not_Be_Able_To_Play_If_Hand_Is_Empty() { _mockHand.Setup(c => c.GetEnumerator()).Returns(Enumerable.Empty <ICard>().GetEnumerator()); var sut = new SimplePlayer("Player", _mockHand.Object, 30, 0, 0); Assert.False(sut.CanPlay); }
public void OnTriggerEnter2D(Collider2D collision) { //Debug.Log("TODO: GO TO NEXT DUNGEON!"); SimplePlayer p = collision.gameObject.GetComponent <SimplePlayer>(); //Debug.Log(p.health); GameStores.SetHealth(p.health); GameStores.SetDefMod(p.shieldModifier); GameStores.SetAtkMod(p.fireDelay); //Debug.Log(p.shieldModifier); GameStores.IncrementLength(); GameStores.IncrementDepth(); if (GameStores.GetDepth() == firstBoss) { SceneManager.LoadScene("BossWall"); } else if (GameStores.GetDepth() == secondBoss) { SceneManager.LoadScene("BossHux"); } else { SceneManager.LoadScene("Dungeon"); } }
private void ChooseEnemyHero(SimplePlayer player) { if (!IsMain) { heroesInAttacked = player; } }
void Update() { if (Scanner != null && target == null) { target = Scanner.Detect(transform); } else { if (Scanner == null) { Debug.LogError("scanner is null"); } } if (target != null) { var playerHP = target.GetComponent <Health>().CurrentHealth; if (playerHP <= 0) { CurrentState = AIstates.Idle; target = null; } } if ((CurrentState != AIstates.Chase && CurrentState != AIstates.Attack) && target != null) { CurrentState = AIstates.Chase; } rb.velocity = Vector3.zero; Switches(); }
public override void InitSettingsPlayer(bool isMain, int idTurn) { isCanMove = new bool[simplePlayerPanelDataSet.ButtonsAbilities.Count]; isStartCoolDown = new bool[simplePlayerPanelDataSet.ButtonsAbilities.Count]; coolDown = new int[simplePlayerPanelDataSet.ButtonsAbilities.Count]; for (int i = 0; i < simplePlayerPanelDataSet.ButtonsAbilities.Count; i++) { isCanMove[i] = false; isStartCoolDown[i] = false; } IsMain = isMain; this.idTurn = idTurn; playerHealth = new PlayerHealth(playerHealthDataSet); playerHealth.onChangeHealth += SetStatusHero; if (IsMain) { mainPlayer = this; panel = new PanelMainSimplePlayer(simplePlayerPanelDataSet); panel.onClickAbilityButton += SetAbility; } InitAbilities(); }
private void ResetPlayer() { playerUpAbility = null; playerAbility = null; playerEnergyAbility = null; heroesInAttacked = null; }
public void SimplePlayer_GetMove() { var mainPlayer = new SimplePlayer(new Participant()); var card1 = SheepCard.JACK_CLUBS; var card2 = SheepCard.N8_HEARTS; new List <SheepCard>() { card1, card2 }.ForEach(c => mainPlayer.AddCard(c)); var playerList = new List <IPlayer>() { new MockPlayer(), new MockPlayer(), mainPlayer, new MockPlayer(), new MockPlayer() }; { var trickMock = GenerateTrickMock(playerList); trickMock.Setup(m => m.IsLegalAddition(card1, mainPlayer)).Returns(true); trickMock.Setup(m => m.IsLegalAddition(card2, mainPlayer)).Returns(false); var cardPlayed = mainPlayer.GetMove(trickMock.Object); Assert.AreEqual(card1, cardPlayed, "Since card1 is legal, that is the card simple player will play"); } { var trickMock = GenerateTrickMock(playerList); trickMock.Setup(m => m.IsLegalAddition(card1, mainPlayer)).Returns(false); trickMock.Setup(m => m.IsLegalAddition(card2, mainPlayer)).Returns(true); var cardPlayed = mainPlayer.GetMove(trickMock.Object); Assert.AreEqual(card2, cardPlayed, "Since card2 is legal, that is the card simple player will play"); } }
void Start() { if (GameSettings.instance == null) { Debug.Log("No game setting data"); return; } gameOverCanvas.SetActive(false); _gameActive = false; loadLevel(GameSettings.instance.getLevelToLoad(), GameSettings.instance.getLoaderToUse()); if (_players != null) { _players.Clear(); } else { _players = new List <SimplePlayer>(); } _players.Add(new SimplePlayer(GameSettings.instance.getPlayerName())); _currentPlayer = _players[0]; //Maybe wait until a button is pressed, who knows. startGame(); }
public void PlayManyGamesTest() { IPlayer player1 = new SimplePlayer(); IPlayer player2 = new DiscardOnlyPlayer(); int NumDrawGames = 0; const int TotalGamesPlayed = 25; for (int gameNumber = 0; gameNumber < TotalGamesPlayed; gameNumber++) { Board board = new Board(); board.AddPlayer(player1); board.AddPlayer(player2); board.PrepGame(); board.PlayGame(); if (board.Winner == null) { NumDrawGames++; } } Debug.WriteLine(string.Format("{0} won {1}, {2} won {3}. {4} Drawn = Total {5}", player1, player1.GamesWon, player2, player2.GamesWon, NumDrawGames, TotalGamesPlayed)); Assert.AreEqual(TotalGamesPlayed, NumDrawGames + player1.GamesWon + player2.GamesWon, "Total number of games won and drawn must match games played."); }
public void SecondRoundShouldLearnGestures() { var player1 = new SimplePlayer(@"Player 1", _Strategy); var player2 = new SimplePlayer(@"Player 2", new MockStrategy(HandGesture.Paper)); var player3 = new SimplePlayer(@"Player 3", new MockStrategy(HandGesture.Scissors)); // Play some initial turns var turns = new Turn[] { new Turn(player1, HandGesture.Rock), new Turn(player2, HandGesture.Paper), new Turn(player3, HandGesture.Scissors) }; // Call the strategy's learner _Strategy.Learn(player1, turns).Wait(); // This strategy just stores plays and picks the winner against them at random // Use the mock random to force the selection // Position 3 will win again paper = scissors // Position 4 will win again scissors = rock _Random.Set(3); var g1 = _Strategy.GetGesture().Result; _Random.Set(4); var g2 = _Strategy.GetGesture().Result; Assert.AreEqual(HandGesture.Scissors, g1, @"The strategy should play Scissors if responding to player 1's last move"); Assert.AreEqual(HandGesture.Rock, g2, @"The strategy should play Rock if responding to player 2's last move"); }
// Start is called before the first frame update void Start() { healthController.SetDeathCallback(Die); sp = GameObject.FindGameObjectWithTag("Player").GetComponent <SimplePlayer>(); //SetDelay(PhaseOne); SetAction(null, delay, PhaseOneStart); au = GetComponent <AudioSource>(); }
/// <summary> /// Simple void /// </summary> /// <param name="_name">Name</param> /// <param name="_typePlayer">Type player</param> /// <param name="_stepFinishPlayer">MainSize and FinishStep</param> private static void SimplePlayerMethod(string _name, string _typePlayer, int _stepFinishPlayer) { Thread simplePlayerThread = new Thread(new ParameterizedThreadStart(SimplePlayerLogic.CalcSimplePlayer)); SimplePlayer simplepl1 = new SimplePlayer(_name: _name, _stepFinish: _stepFinishPlayer); MainList.AddMainList(new MainList(_countPlayers: 1, _namePlayer: _name, _typePlayer: _typePlayer, _stepFinishPlayer: _stepFinishPlayer)); simplePlayerThread.Start(simplepl1); }
void Start() { _rb = GetComponent <Rigidbody2D>(); _player = GetComponent <SimplePlayer>(); updateLevel(); updateGravity(); }
public void SetInvalidPlayerTest() { Board board = DiscardOnly2PlayerSetup(); IPlayer unknownPlayer = new SimplePlayer(); board.SetCurrentPlayer(unknownPlayer); }
// Start is called before the first frame update void Start() { // Use callbacks to add them to the player SimplePlayer sp = GameObject.FindGameObjectWithTag("Player").GetComponent <SimplePlayer>(); sp.SetListeners(OnChangeColour, OnAddColour); OnAddColour(0); }
public void Should_Construct_Properly(int initialHealth, int initialMana, int maxMana) { var sut = new SimplePlayer("Player", _mockHand.Object, initialHealth, initialMana, maxMana); Assert.True(_mockHand.Object.Equals(sut.Hand)); Assert.Equal(initialHealth, sut.Health); Assert.Equal(initialMana, sut.Mana); Assert.Equal(initialMana, sut.ManaSlot); }
private static Board Default2PlayerSetup() { Board board = new Board(); IPlayer player1 = new SimplePlayer(); IPlayer player2 = new SimplePlayer(); board.AddPlayer(player1); board.AddPlayer(player2); return(board); }
private void OnTriggerEnter2D(Collider2D other) { if (other.tag == "Player") { TextRef.textBuilder.CreateText(transform.position, "+DEFENCE", Color.blue, Color.black); SimplePlayer player = other.GetComponent <SimplePlayer>(); player.alterDefencePower(fractionalIncrease); Destroy(gameObject); } }
private SimplePlayer<StubModel> MakePlayer(IEnumerable<PlayEvent<StubModel>> changes) { var evtPlayer = new SimplePlayer<StubModel>(); foreach (var playEvent in changes) { evtPlayer.Load(playEvent); } return evtPlayer; }
// Use this for initialization void Start() { //Quick and Dirty solution Problem Gameobject/Script variables get cleared on Play world = GetComponent <World>(); player1 = GameObject.Find("player1").GetComponent <SimplePlayer>(); player2 = GameObject.Find("player2").GetComponent <SimplePlayer>(); player1.TurnStart(); EventManager.TurnStart(currentPlayer); print("started"); }
public void ShouldReceiveDamage(int damage, int initialHealth) { var sut = new SimplePlayer("Player", _mockHand.Object, initialHealth, 0, 0); sut.ReceiveDamage(damage); int remainingHealth = Math.Max(initialHealth - damage, 0); Assert.Equal(remainingHealth, sut.Health); }
public void ShouldUseMana(int usedMana, int initialMana) { var sut = new SimplePlayer("Player", _mockHand.Object, 30, initialMana, initialMana); sut.UseMana(usedMana); int remainingMana = Math.Max(initialMana - usedMana, 0); Assert.Equal(remainingMana, sut.Mana); }
private void OnTriggerEnter2D(Collider2D other) { if (other.tag == "Player") { SimplePlayer player = other.GetComponent <SimplePlayer>(); player.healDamage(healthRestore); au.Play(); Destroy(gameObject); } }
public static BitmapSource GetImageForFile(string filename) { var bitmap = SimplePlayer.GetFrameFromFile(filename, 3000, false, VFSimplePlayerEngine.LAV); if (bitmap == null) { return(CreateBitmapSource(Colors.Black)); } return(BitmapConv(bitmap)); }
public AudioService() : base(1, ThreadPriority.AboveNormal) { this.simplePlayer = new SimplePlayer(); this.memoryStreamsPool = new ObjectPool <MemoryStream>(2); for (int i = 0; i < 2; i++) { this.memoryStreamsPool.Push(new MemoryStream()); } this.actualMemoryStream = this.memoryStreamsPool.Pop(); }
public MainWindow() { InitializeComponent(); _videoPlayer = new SimplePlayer(null); _videoPlayer.OnVideoFrame += VideoCapture1_OnVideoFrameBuffer; _videoPlayer.OnError += VideoCapture1_OnError; _videoCapture = new SimpleCapture(null); _videoCapture.OnVideoFrame += VideoCapture1_OnVideoFrameBuffer; _videoCapture.OnError += VideoCapture1_OnError; }
public void OnTriggerEnter2D(Collider2D other) { if (other.tag == "Player") { TextRef.textBuilder.CreateText(transform.position, "+SPEED", Color.green, Color.black); SimplePlayer player = other.GetComponent <SimplePlayer>(); player.speedPowerUp(duration, power); au.Play(); Destroy(gameObject); } }
void Awake() { s_Instance = this; controller = GetComponent <CharacterController>(); cam = camMount.GetComponentInChildren <Camera>(); anim = GetComponentInChildren <Animator>(); shot = GetComponent <UbhShotCtrl>(); mouseLook.Init(transform, camMount.transform); layermask = 1 << 8; layermask = ~layermask; ResetDash(); }
public void OnTriggerEnter2D(Collider2D other) { bool foundColour = false; if (other.tag == "Player") { SimplePlayer player = other.GetComponent <SimplePlayer>(); player.changeAttackColour(colourRGB); au.Play(); Destroy(gameObject); } }
void Update() { if (target == null) { target = Scanner.Detect(transform); } if (target != null && CurrentState != AIstates.Chase) { CurrentState = AIstates.Chase; } Switches(); }
private PlayerData GetPlayerData(SimplePlayer player) { return(new PlayerData { Width = 143, Margin = new Padding(0, 1, 0, 1), ClassImage = player.ProfessionIcon, DisplayName = player.Account.TrimEnd("0123456789.".ToCharArray()), SubGroup = player.Group.ToString(), DPS = player.DpsTargets.ToString() }); }
public void CanSolveABoardWithTwoForcedMovesRemaining() { int[,] data = new int[,] { {9,6,2,7,1,5,8,3,4}, {4,7,8,9,6,3,5,1,2}, {3,1,5,4,2,8,6,9,7}, {1,2,7,6,5,9,3,4,8}, {8,9,4,2,3,1,7,5,6}, {5,3,6,8,7,4,9,2,1}, {6,5,3,1,4,7,2,8,9}, {7,8,1,3,9,2,4,0,5}, {2,4,9,5,8,6,1,7,0} }; var moveFinder = new SimpleMoveFinder(); var player = new SimplePlayer(moveFinder, new SimpleEvaluator(moveFinder)); var result = player.SolveBoard(new Board(data)); Assert.Equal(2, result.MovesPlayed.Count); var mv1 = from m in result.MovesPlayed where m.Row == 8 && m.Column == 8 && m.Value == 3 select m; var mv2 = from m in result.MovesPlayed where m.Row == 7 && m.Column == 7 && m.Value == 6 select m; int[,] solveddata = new int[,] { {9,6,2,7,1,5,8,3,4}, {4,7,8,9,6,3,5,1,2}, {3,1,5,4,2,8,6,9,7}, {1,2,7,6,5,9,3,4,8}, {8,9,4,2,3,1,7,5,6}, {5,3,6,8,7,4,9,2,1}, {6,5,3,1,4,7,2,8,9}, {7,8,1,3,9,2,4,6,5}, {2,4,9,5,8,6,1,7,3} }; IBoard solvedBoard = new Board(solveddata); Assert.Equal(solvedBoard, result.CurrentBoard.Board); Assert.NotNull(mv1); Assert.NotNull(mv2); }
/// <summary> /// 获得玩家的简单信息 /// </summary> /// <param name="player"></param> /// <returns></returns> public static SimplePlayer GetSimplePlayer(this Player player) { var ss = player.GetComponent<SimplePlayer>(); if (ss == null) { ss = new SimplePlayer { Id = player.Id, Name = player.Name, Sex = player.Sex, }; player.RegisterComponent(ss); } ss.Direction = player.Direction; ss.Postion = player.Postion; return ss; }
public void AddCommand() { // init const int CurrentVersion = 0; const int ExpectedVersion = CurrentVersion + 1; const int AddValue = 1; var model = new StubModel { AggregateId = new AggregateId<StubModel>("1"), LatestVersion = CurrentVersion, Value = 1 }; long expectedVal = model.Value + AddValue; var expectedEvt = new StubAddedEvent(new AggregateId<StubModel>("1"), AddValue) { Version = ExpectedVersion }; // ----note the 'ed'---------^^ // run // validation exception Assert.Throws<InvalidOperationException>(() => new StubAddCommand { AddValue = -1 }.ExecuteOn(model)); // successful command var actualEvt = new StubAddCommand { AddValue = AddValue }.ExecuteOn(model); this.assertEvents(expectedEvt, actualEvt); // playback var player = new SimplePlayer<StubModel>(); player.Load(actualEvt); player.PlayFor(model); // end value after playback Assert.AreEqual(expectedVal, model.Value); }
public void CanSolveABoardWithOneMoveRemaining() { int[,] data = new int[,] { {9,6,2,7,1,5,8,3,4}, {4,7,8,9,6,3,5,1,2}, {3,1,5,4,2,8,6,9,7}, {1,2,7,6,5,9,3,4,8}, {8,9,4,2,3,1,7,5,6}, {5,3,6,8,7,4,9,2,1}, {6,5,3,1,4,7,2,8,9}, {7,8,1,3,9,2,4,6,5}, {2,4,9,5,8,6,1,7,0} }; var moveFinder = new SimpleMoveFinder(); var player = new SimplePlayer(moveFinder, new SimpleEvaluator(moveFinder)); var result = player.SolveBoard(new Board(data)); int[,] solveddata = new int[,] { {9,6,2,7,1,5,8,3,4}, {4,7,8,9,6,3,5,1,2}, {3,1,5,4,2,8,6,9,7}, {1,2,7,6,5,9,3,4,8}, {8,9,4,2,3,1,7,5,6}, {5,3,6,8,7,4,9,2,1}, {6,5,3,1,4,7,2,8,9}, {7,8,1,3,9,2,4,6,5}, {2,4,9,5,8,6,1,7,3} }; IBoard solvedBoard = new Board(solveddata); Assert.Equal(solvedBoard, result.CurrentBoard.Board); Assert.Equal(1, result.MovesPlayed.Count); Assert.Equal(3, result.MovesPlayed[0].Value); Assert.Equal(8, result.MovesPlayed[0].Row); Assert.Equal(8, result.MovesPlayed[0].Column); }
public void CanSolveASimpleBoard() { IBoard board = new Board("8..3......9.....7...3584...4...9...2...4.7...78...1..5..96...2.....5..31........6"); var moveFinder = new SimpleMoveFinder(); var player = new SimplePlayer(moveFinder, new SimpleEvaluator(moveFinder)); var result = player.SolveBoard(board); IBoard solvedBoard = new Board("812379654594126378673584219431895762925467183786231945159643827267958431348712596"); Assert.Equal(solvedBoard, result.CurrentBoard.Board); }
public HomeController() { var finder = new SimpleMoveFinder(); Player = new SimplePlayer(finder, new SimpleEvaluator(finder)); }
public void CanSolveAHardBoard01() { IBoard board = new Board("...........3......6.1.9.4....2.1.9...9.42.1....79..32..36.48..98.....71.2.9.7...3"); var moveFinder = new SimpleMoveFinder(); var player = new SimplePlayer(moveFinder, new SimpleEvaluator(moveFinder)); var result = player.SolveBoard(board); IBoard solvedBoard = new Board("475381692923764581681592437562813974398427165147956328736148259854239716219675843"); Assert.Equal(solvedBoard, result.CurrentBoard.Board); }
public void CanSolveAHardBoard02() { IBoard board = new Board("..15.....4......7..6..9.1..3....15...9..6...8..57...4..8.1....2..3....5......26.."); var moveFinder = new SimpleMoveFinder(); var player = new SimplePlayer(moveFinder, new SimpleEvaluator(moveFinder)); var result = player.SolveBoard(board); IBoard solvedBoard = new Board("931576824452813976867294135328941567794365218615728349586137492243689751179452683"); Assert.Equal(solvedBoard, result.CurrentBoard.Board); }
public void CanSolveAHardBoard03() { IBoard board = new Board("5.19..6.2.3..2..7..........1.....8...7..4..1...6.....5..........4..9..3.7.3..15.4"); var moveFinder = new SimpleMoveFinder(); var player = new SimplePlayer(moveFinder, new SimpleEvaluator(moveFinder)); var result = player.SolveBoard(board); IBoard solvedBoard = new Board("581937642439625178267814953154369827978542316326178495612453789845796231793281564"); Assert.Equal(solvedBoard, result.CurrentBoard.Board); }
public void CanSolveAMediumBoard01() { IBoard board = new Board(".5..8..3.16...5.74...9...6..4..7.1.2.........5.1.6..4..7...8.1.41.7...23.3..1..9."); var moveFinder = new SimpleMoveFinder(); var player = new SimplePlayer(moveFinder, new SimpleEvaluator(moveFinder)); var result = player.SolveBoard(board); IBoard solvedBoard = new Board("954687231168325974327941568643879152792154386581263749279438615415796823836512497"); Assert.Equal(solvedBoard, result.CurrentBoard.Board); }
public void WillReturnEmptyListWhenTheBoardIsAlreadySolved() { int[,] data = new int[,] { {9,6,2,7,1,5,8,3,4}, {4,7,8,9,6,3,5,1,2}, {3,1,5,4,2,8,6,9,7}, {1,2,7,6,5,9,3,4,8}, {8,9,4,2,3,1,7,5,6}, {5,3,6,8,7,4,9,2,1}, {6,5,3,1,4,7,2,8,9}, {7,8,1,3,9,2,4,6,5}, {2,4,9,5,8,6,1,7,3} }; var moveFinder = new SimpleMoveFinder(); var player = new SimplePlayer(moveFinder, new SimpleEvaluator(moveFinder)); var result = player.SolveBoard(new Board(data)); int[,] solveddata = new int[,] { {9,6,2,7,1,5,8,3,4}, {4,7,8,9,6,3,5,1,2}, {3,1,5,4,2,8,6,9,7}, {1,2,7,6,5,9,3,4,8}, {8,9,4,2,3,1,7,5,6}, {5,3,6,8,7,4,9,2,1}, {6,5,3,1,4,7,2,8,9}, {7,8,1,3,9,2,4,6,5}, {2,4,9,5,8,6,1,7,3} }; IBoard solvedBoard = new Board(solveddata); Assert.Equal(solvedBoard, result.CurrentBoard.Board); Assert.Equal(0, result.MovesPlayed.Count); }
public void CanSolveADiabolicalBoard01() { IBoard board = new Board("...7.4..5.2..1..7.....8...2.9...625.6...7...8.532...1.4...9.....3..6..9.2..4.7..."); var moveFinder = new SimpleMoveFinder(); var player = new SimplePlayer(moveFinder, new SimpleEvaluator(moveFinder)); var result = player.SolveBoard(board); IBoard solvedBoard = new Board("981724365324615879765983142197836254642571938853249716476398521538162497219457683"); Assert.Equal(solvedBoard, result.CurrentBoard.Board); }