public void AttackGathersAttackerStats() { var stats = CreateTestStats(); var mockAttack = new Mock <IAttack>(); mockAttack.Setup(attack => attack.AddAssaulterStrength(25)); mockAttack.Setup(attack => attack.AddAssaulterIntellect(28)); mockAttack.Setup(attack => attack.AddAssaulterDexterety(26)); mockAttack.Setup(attack => attack.AddAssaulterAttack(10)); mockAttack.Setup(attack => attack.AddAssaulterMagicAttack(30)); mockAttack.Setup(attack => attack.AddAssaulterAccuracy(33)); mockAttack.Setup(attack => attack.AddAssaulterCriticalChance(16)); var e = AttackTest.ThisAttacksCh1(null, null, mockAttack.Object); stats.ReceiveEvent(e); mockAttack.VerifyAll(); }
// Update is called once per frame void Update() { if (_isWallShaking) { ShakeWall(); } if (_isShaderNeeded) { if (_shaderLerp <= 1 && !_hasShaderCompletelyAppeared) { _shaderLerp += Time.deltaTime * _shaderLerpMax; if (_shaderLerp >= 1) { _shaderLerp = 1; _hasShaderCompletelyAppeared = true; } } else if (_shaderLerp >= -1 && _hasShaderCompletelyAppeared) { _shaderLerp -= Time.deltaTime * _shaderLerpMax; if (_shaderLerp <= -1) { _shaderLerp = -1; _hasShaderCompletelyAppeared = false; _isShaderNeeded = false; } } _shaderRenderer.material.SetFloat("_Etatdudissolve", _shaderLerp); } if (_attackTestOnCollision != null) { lerpTimerRatio += Time.deltaTime; _attackTestOnCollision.GetPlayerScoreImage().color = Color32.Lerp(_attackTestOnCollision.GetPlayerScoreImage().color, new Color32(255, 255, 255, 100), lerpTimerRatio); if (lerpTimerRatio >= 1) { lerpTimerRatio = 0; _attackTestOnCollision = null; } } if (lastEjectedPlayer != null && lastEjectedPlayer.GetComponent <AttackTest>().hasPositionBeenSet()) { _gameManagerScript.currentFace = _nextFace - 1; _arenaRotationScript._currentFace = _nextFace - 1; lastEjectedPlayer = null; } //si la caméra est en train de changer de face, désactive les sprites ainsi que les colliders des murs, reset la vie des murs et //actualise la face actuelle de la caméra if (_arenaRotationScript._isTurning) { _hasCreatedArrayTwo = false; _hasCreatedArray = false; _wallProprieties.UpdateProprieties(); _wallManagerScript.WhichWall(_wallProprieties); _wallProprieties.IAmConnectedIMustConnect(); InitiateWall(); _wallCollider[0].enabled = true; _wallCollider[1].enabled = false; _wallMeshRenderer.enabled = true; _currentFace = _arenaRotationScript._currentFace; _lastHit = false; wallLife = _wallLifeMax; if (!_wallProprieties.GetIsBouncy()) { _wallMesh.mesh = wallAppearance[0]; _wallShadowMeshRenderer.enabled = true; _wallShadowMesh.mesh = wallShadowAppearance[0]; } else { _wallBambouAppearance.sharedMesh = wallAppearance[0]; _wallBambouAppearance.enabled = true; _wallShadowMeshRendererBambou.enabled = true; _wallShadowMeshRendererBambou.sharedMesh = wallShadowAppearance[0]; } if (!_wallProprieties.GetIsIndestructible()) { if (_wallProprieties.GetIsBouncy()) { _meshMaterialsBambou[0].color = new Color32(30, 255, 0, 255); } //réinitialise le tableau de matériaux du mur normal else { _meshMaterials[0].color = new Color32(30, 255, 0, 255); Material[] temp = new Material[_wallMeshRendererOriginalMaterials.Length]; for (int i = 0; i < temp.Length; i++) { temp[i] = _wallMeshRendererOriginalMaterials[i]; } _wallMeshRenderer.materials = temp; } } if (gameObject.layer == 15) { gameObject.SetActive(false); _wallShadowMeshRenderer.enabled = false; if (_wallShadowMeshRendererBambou != null) { _wallShadowMeshRendererBambou.enabled = false; } } if (gameObject.layer == 14) { gameObject.SetActive(true); BoxCollider2D[] boxColliderTab = GetComponents <BoxCollider2D>(); for (int i = 0; i < boxColliderTab.Length; i++) { boxColliderTab[i].enabled = false; } } } if (wallLife == _wallLifeMax) { if (_wallProprieties.GetIsBouncy()) { if (_hasPlayerCollided) { _bouncyAnimator.SetBool("isState4", true); } else { _bouncyAnimator.SetBool("isState4", false); } } } if (wallLife <= 0) { _lastHit = true; if (transform.GetChild(3).gameObject.activeSelf) { transform.GetChild(3).gameObject.SetActive(false); } if (numberWallState > numberWallStateMax - 4) { ShakeScreen(); } _wallMeshRenderer.enabled = false; if (!_wallProprieties.GetIsBouncy()) { _wallShadowMeshRenderer.enabled = false; } else { _wallBambouAppearance.enabled = false; _wallShadowMeshRendererBambou.enabled = false; } _wallCollider[0].enabled = false; _wallCollider[1].enabled = true; } else if (wallLife < _wallLifeMax && wallLife >= (_wallLifeMax * 0.66)) { if (numberWallState > numberWallStateMax - 1) { ShakeScreen(); } if (!_wallProprieties.GetIsBouncy()) { _wallMesh.mesh = wallAppearance[1]; _wallShadowMesh.mesh = wallShadowAppearance[1]; } else { _wallBambouAppearance.sharedMesh = wallAppearance[1]; _wallShadowMeshRendererBambou.sharedMesh = wallShadowAppearance[1]; if (_hasPlayerCollided) { _bouncyAnimator.SetBool("isState3", true); } else { _bouncyAnimator.SetBool("isState3", false); } } } else if (wallLife < (_wallLifeMax * 0.66) && wallLife > (_wallLifeMax * 0.33)) { if (numberWallState > numberWallStateMax - 2) { ShakeScreen(); } if (!_wallProprieties.GetIsBouncy()) { _wallMesh.mesh = wallAppearance[2]; _wallShadowMesh.mesh = wallShadowAppearance[2]; //on change le nombre de matériaux du mur normal car son mesh a changé if (!_wallProprieties.GetIsIndestructible() && !_hasCreatedArray) { Material[] temp = new Material[(3)]; /*_wallMeshRenderer.materials.Length - 2*/ //valeur d'avant au cas où bugg for (int i = 0; i < temp.Length; i++) { temp[i] = _wallMeshRenderer.materials[i]; } _wallMeshRenderer.materials = temp; _hasCreatedArray = true; } } else { _wallBambouAppearance.sharedMesh = wallAppearance[2]; _wallShadowMeshRendererBambou.sharedMesh = wallShadowAppearance[2]; if (_hasPlayerCollided) { _bouncyAnimator.SetBool("isState2", true); } else { _bouncyAnimator.SetBool("isState2", false); } } } else if (wallLife < (_wallLifeMax * 0.33) && wallLife > 0) { if (numberWallState > numberWallStateMax - 3) { ShakeScreen(); } if (!_wallProprieties.GetIsBouncy()) { _wallMesh.mesh = wallAppearance[3]; _wallShadowMesh.mesh = wallShadowAppearance[3]; //on change le nombre de matériaux du mur normal car son mesh a changé if (!_wallProprieties.GetIsIndestructible() && !_hasCreatedArrayTwo) { Material[] temp = new Material[(2)]; /*_wallMeshRenderer.materials.Length - 1*/ //valeur d'avant au cas où bugg for (int i = 0; i < temp.Length; i++) { temp[i] = _wallMeshRenderer.materials[i]; } _wallMeshRenderer.materials = temp; _hasCreatedArrayTwo = true; } } else { _wallBambouAppearance.sharedMesh = wallAppearance[3]; _wallShadowMeshRendererBambou.sharedMesh = wallShadowAppearance[3]; if (_hasPlayerCollided) { _bouncyAnimator.SetBool("isState1", true); } else { _bouncyAnimator.SetBool("isState1", false); } } } }
private void OnTriggerEnter2D(Collider2D collision) { _playerOnCollision = collision.gameObject.GetComponent <PlayerEntity>(); _attackTestOnCollision = collision.gameObject.GetComponent <AttackTest>(); Rigidbody2D _playerCollisionRB = collision.gameObject.GetComponent <Rigidbody2D>(); if (_lastHit) { _playerCollisionRB.velocity = _playerCollisionRB.velocity.normalized * _wallManagerScript.ejectionPower; if (_gameManagerScript.currentPlayersOnArena > 2) { _wallMeshRenderer.enabled = false; _wallShadowMeshRenderer.enabled = false; _playerOnCollision.enabled = false; _playerOnCollision.newRound(); _playerOnCollision.DesactiveCollider(); _scoreManagerScript.ChangeScore(_gameManagerScript.currentPlayersOnArena, int.Parse(collision.gameObject.tag.Substring(collision.gameObject.tag.Length - 1))); _gameManagerScript.ThisPlayerHasLost(collision.gameObject.tag); _gameManagerScript.currentPlayersOnArena--; } else if (_gameManagerScript.currentPlayersOnArena <= 2) { Debug.Log("CurrentFace : " + _currentFace); Debug.Log("Wall qui change : " + this.gameObject.name); switch (this.gameObject.name) { case "WallNorthEast": _nextFace = _wallManagerScript.WallFaceChange(_gameManagerScript._wallNorthEastTab, _currentFace); break; case "WallNorthWest": _nextFace = _wallManagerScript.WallFaceChange(_gameManagerScript._wallNorthWestTab, _currentFace); break; case "WallSouthWest": _nextFace = _wallManagerScript.WallFaceChange(_gameManagerScript._wallSouthWestTab, _currentFace); break; case "WallSouth": _nextFace = _wallManagerScript.WallFaceChange(_gameManagerScript._wallSouthTab, _currentFace); break; case "WallSouthEast": _nextFace = _wallManagerScript.WallFaceChange(_gameManagerScript._wallSouthEastTab, _currentFace); break; } //renvoie la prochaine face vers le script de rotation de caméra _wallCollider[0].enabled = false; // _wallCollider.isTrigger = false; _playerOnCollision.enabled = false; if (_gameManagerScript.playerList.Count > 2) { if (_gameManagerScript.currentPlayersOnArena == 2 && !_scoreManagerScript.GetSuddenDeath()) { _scoreManagerScript.ChangeScore(2, int.Parse(collision.gameObject.tag.Substring(collision.gameObject.tag.Length - 1))); _gameManagerScript.ThisPlayerHasLost(collision.gameObject.tag); _gameManagerScript.currentPlayersOnArena--; _scoreManagerScript.ChangeScore(1, int.Parse(_gameManagerScript.GetFirstCurrentPlayersItem().gameObject.tag.Substring(_gameManagerScript.GetFirstCurrentPlayersItem().gameObject.tag.Length - 1))); } else if (_gameManagerScript.currentPlayersOnArena == 2 && _scoreManagerScript.GetSuddenDeath()) { _scoreManagerScript.ChangeScore(2, int.Parse(collision.gameObject.tag.Substring(collision.gameObject.tag.Length - 1))); _gameManagerScript.ThisPlayerHasLost(collision.gameObject.tag); _gameManagerScript.currentPlayersOnArena--; _scoreManagerScript.ChangeScore(1, int.Parse(_gameManagerScript.GetFirstCurrentPlayersItem().gameObject.tag.Substring(_gameManagerScript.GetFirstCurrentPlayersItem().gameObject.tag.Length - 1))); } } else { if (_gameManagerScript.currentPlayersOnArena == 2) { _scoreManagerScript.ChangeScore(4, int.Parse(collision.gameObject.tag.Substring(collision.gameObject.tag.Length - 1))); _gameManagerScript.ThisPlayerHasLost(collision.gameObject.tag); _gameManagerScript.currentPlayersOnArena--; _scoreManagerScript.ChangeScore(1, int.Parse(_gameManagerScript.GetFirstCurrentPlayersItem().gameObject.tag.Substring(_gameManagerScript.GetFirstCurrentPlayersItem().gameObject.tag.Length - 1))); } } _gameManagerScript.ResetCurrentPlayers(); lastEjectedPlayer = collision.gameObject; _lastHit = false; } } }
// Start is called before the first frame update void Start() { _attackTestScript = transform.parent.GetComponent <AttackTest>(); }