public void CheckerOnPositionTest2() { TurnSystem.InitializeData(); Checker testObj = CheckerManager.BrownCheckers[0]; GameMechanics.ResetGame(); Assert.AreEqual(CheckerManager.CheckerOnPosition(testObj.GameObj.transform.position), testObj); }
public void CheckerOnPositionTest() { TurnSystem.InitializeData(); Checker testObj = CheckerManager.BlueCheckers[0]; GameMechanics.ResetGame(); Assert.AreEqual(CheckerManager.CheckerOnPosition(new Vector3(10, 0.3f, 10)), testObj); }
public static bool IsJumpPossible(GameObject gameObjChecker, GameObject gameObjField) { //Search checker and fields array for variable with same GameObject as given as argument Checker checker = CheckerManager.CheckerWithGameobject(gameObjChecker); Field field = FieldManager.FieldWithGameObject(gameObjField); //Check if field is free if (!IsFieldFree(field.GameObject)) { return(false); } //Check if jumping distance is correct double distance = Vector3.Distance(checker.GameObj.transform.position, field.GameObject.transform.position); if (distance > 2.95f || distance < 2.8f) { return(false); } //Check if move isnt backwards && checker isnt a king if (!checker.IsKing) { if (checker.PlayerColor == "Brown" && (checker.GameObj.gameObject.transform.position.z - field.GameObject.transform.position.z) > 0) { return(false); } if (checker.PlayerColor == "Blue" && (checker.GameObj.transform.position.z - field.GameObject.transform.position.z) < 0) { return(false); } } //Check if enemy is between checker and field Vector3 enemyPos = checker.GameObj.transform.position; enemyPos.x = (checker.GameObj.transform.position.x + field.GameObject.transform.position.x) / 2; enemyPos.z = (checker.GameObj.transform.position.z + field.GameObject.transform.position.z) / 2; enemyPos.y = 0.3f; //Check if player wants to jump over enemy or over free field if (!IsAnyCheckerOnPosition(enemyPos)) { return(false); } //If player wants to jump over another checker, check if that checker is an enemy else { if (CheckerManager.CheckerOnPosition(enemyPos).PlayerColor == "Blue" && checker.PlayerColor == "Blue") { return(false); } if (CheckerManager.CheckerOnPosition(enemyPos).PlayerColor == "Brown" && checker.PlayerColor == "Brown") { return(false); } } return(true); }