void Shoot(GamerController mainGameController, CharacterObject currentPlayer, int currentPlayerIndex, int opponentIndex) { // This is the ray which will hit the target RaycastHit hit; // This is for the effect of shooting muzzleFlash.Play(); AudioClip clip = gunshot.clip; gunshot.PlayOneShot(clip); // Updates the stamina of the player mainGameController.UpdateEnergy(0.5f); // This condition is true only when we have hit something with our ray if (Physics.Raycast(this.gameObject.transform.position, this.gameObject.transform.forward, out hit, Range)) { if (hit.transform.tag == "Player") { // This causes damage mainGameController.TakeDamage(opponentIndex); } } else { //Debug.Log("We didn't hit anything but we fired !!!"); } }
void OnCollisionEnter(Collision collision) { GamerController gamerController = GetGameController(); List <CharacterObject> characterObjects = gamerController.GetAllCharacterObjects(); //get contact point Vector3 collisionPosition = collision.contacts[0].point; for (int i = 0; i <= 1; ++i) { Vector3 characterPosition = characterObjects[i].charObject.transform.position; float distance = Vector3.Distance(collisionPosition, characterPosition); if (distance < impactDistance) { characterObjects[i].charActions.Damage(); int health = (int)((1 - (distance / impactDistance)) * 20); gamerController.UpdateHealth(characterObjects[i], -health); } } GameObject exp = Instantiate(explosion, transform.position, transform.rotation); Destroy(gameObject); Destroy(exp, 2); }
// Trigger events - this basically collects th gun orb which allows the player get the power to use the gun private void OnTriggerEnter(Collider col) { GamerController mainGameController = GetGameController(); CharacterObject currentPlayer = mainGameController.GetCurrentCharacterProperties(); if (col.name.StartsWith("FlareMobile")) { currentPlayer.WeaponAllowed = true; mainGameController.UpdateHealth(currentPlayer, 20f); Destroy(col.gameObject); } }
public void OnVerAngChange(float val) { GamerController gameController = GameObject.FindWithTag("GameController").GetComponent <GamerController>(); GameObject currentCharacter = gameController.GetCurrentCharacterProperties().charObject; //change Grenade throw angle GameObject grenade = currentCharacter.transform.Find("Grenade").gameObject; grenade.transform.localEulerAngles = new Vector3(-45 * val, grenade.transform.localEulerAngles.y, grenade.transform.localEulerAngles.z); //Render arc currentCharacter.transform.Find("ProjectilePath").GetComponent <LaunchArcScript>().RenderArc(45 * val); }
// Update is called once per frame void Update() { if (CrossPlatformInputManager.GetButtonDown("CannonShoot")) { GameObject cannon = gameObject.transform.parent.gameObject; if (cannon.name.Equals("Cannon" + Cannons.cannonSelected)) { ShootCannon(); GamerController mainGameController = GetGameController(); // Updates the stamina of the player mainGameController.UpdateEnergy(40f); } } }
// Update is called once per frame void Update() { if (CrossPlatformInputManager.GetButtonDown("Fire")) { GamerController mainGameController = GetGameController(); int currentPlayerIndex = mainGameController.GetCurrentPlayerIndex(); CharacterObject currentObject = mainGameController.GetCharacterProperties(currentPlayerIndex); // Fire only when both are originating from the same object if (canFireCheck(currentObject) && currentObject.weaponName != "Grenade") { currentObject.charActions.Attack(); Shoot(mainGameController, currentObject, currentPlayerIndex, (currentPlayerIndex + 1) % 2); } } }
// Update is called once per frame void Update() { if (CrossPlatformInputManager.GetButtonDown("Fire")) { /*GamerController mainGameController = GetGameController(); * int currentPlayerIndex = mainGameController.GetCurrentPlayerIndex(); * * Debug.Log("Here we have index:"+currentPlayerIndex);*/ GamerController mainGameController = GetGameController(); CharacterObject currentObject = mainGameController.GetCurrentCharacterObject(); // Fire only when both are originating from the same object if (/*canFireCheck(currentObject) && */ currentObject.weaponName.Equals("Grenade")) { currentObject.charActions.Attack(); ThrowGrenade(); mainGameController.UpdateEnergy(20f); } } }
public async Task Create_GivenTicket_ExpectAICreated() { //Arrange var mockGamerRepo = Substitute.For <IGamerRepository>(); mockGamerRepo.CreateGamerAsync(Arg.Any <string>()).Returns(Task.CompletedTask); var vault = Substitute.For <IVault>(); var controller = new GamerController(mockGamerRepo); var request = new SubmissionRequest { Ticket = "Ticket", Token = "Token" }; //Act var action = await controller.Create(request); var createResponse = action as OkResult; //Assert Assert.IsNotNull(createResponse); await mockGamerRepo.Received(1).CreateGamerAsync("Ticket"); }
static GamerController instance; //静态实例类 void Awake() //在Awake中赋值 { instance = this; }
private GamerController GetGameController() { GamerController gameController = GameObject.FindWithTag("GameController").GetComponent <GamerController>(); return(gameController); }