public void TestPlayerDeath() { GameObject testObject = new GameObject(); //add playercontroller to the object testObject.AddComponent <playerController>(); //get the instance of the playercontroller playerControllerScript = testObject.GetComponent <playerController>(); //set health to 100 playerControllerScript.health = 100; //add required components testObject.AddComponent <playerInputController>(); playerInputController input = testObject.GetComponent <playerInputController>(); Debug.Log(input.isActiveAndEnabled); Debug.Log(playerControllerScript.health); playerControllerScript.takeDamage(1000); Debug.Log(input.isActiveAndEnabled); Debug.Log(playerControllerScript.health); // this.gameObject.AddComponent<DeathAnimation>(); Assert.That(input.isActiveAndEnabled, Is.False, "Testing is playerinput is disabled: "); Assert.That(testObject.GetComponent <DeathAnimation>().isActiveAndEnabled, Is.True, "Testing is death animation added: "); Assert.That(playerControllerScript.isActiveAndEnabled, Is.False, "Testing is playercontroller is disable: "); }
// Use this for initialization void Start() { powerup = GameObject.FindGameObjectWithTag("Player").GetComponent <PowerUp>(); player = GameObject.FindGameObjectWithTag("Player").GetComponent <playerController>(); input = GameObject.FindGameObjectWithTag("Player").GetComponent <playerInputController>(); pause = false; }
// Start is called before the first frame update void Start() { sprite = GetComponent <SpriteRenderer>(); if (hinput.gamepad.Count > playerNumber) { inputController = GamePadInputController.CreateGamepadInputController(true, playerNumber, false); } else { inputController = KeyboardInputController.CreateKeyboardInputController(true, this.moveUp, this.moveDown, this.moveLeft, this.moveRight, this.action, this.shiftLeft, this.shiftRight); } }
public void TestUPVerticalAxis() { GameObject testObject = new GameObject(); testObject.AddComponent <playerInputController>(); input = testObject.GetComponent <playerInputController>(); fakeInput.GetAxisRaw(Arg.Is("VerticalLook")).Returns(1.0f); input.InputInterface = fakeInput; input.getCurrentInput(); Actualx = input.Lookv; Assert.AreEqual(Expectedx, Actualx, "Testing UP: "); }
public void TestDHorizontalAxis() { GameObject testObject = new GameObject(); testObject.AddComponent <playerInputController>(); input = testObject.GetComponent <playerInputController>(); fakeInput.GetAxisRaw(Arg.Is("Horizontal")).Returns(-1.0f); input.InputInterface = fakeInput; input.getCurrentInput(); Actualh = input.Moveh; Assert.AreEqual(Expectedh2, Actualh, "Testing D: "); }
public void TestFireAxis() { GameObject testObject = new GameObject(); testObject.AddComponent <playerInputController>(); input = testObject.GetComponent <playerInputController>(); fakeInput.GetAxisRaw(Arg.Is("Fire1")).Returns(1.0f); input.InputInterface = fakeInput; input.getCurrentInput(); Actualf = input.f; Assert.AreEqual(Expectedf, Actualf, "Testing FIRE: "); }
public void TestLEFTHorizontalAxis() { GameObject testObject = new GameObject(); testObject.AddComponent <playerInputController>(); input = testObject.GetComponent <playerInputController>(); fakeInput.GetAxisRaw(Arg.Is("HorizontalLook")).Returns(1.0f); input.InputInterface = fakeInput; input.getCurrentInput(); Actualz = input.Lookh; Assert.AreEqual(Expectedz, Actualz, "Testing LEFT: "); }
// Start is called before the first frame update void Start() { rb2d = GetComponent <Rigidbody2D>(); if (hinput.gamepad.Count > playerNumber) { inputController = GamePadInputController.CreateGamepadInputController(false, playerNumber); } else { inputController = KeyboardInputController.CreateKeyboardInputController(false, this.moveUp, this.moveDown); } //inputController = GamePadInputController.CreateGamepadInputController(false, playerNumber); }
// Use this for initialization void Start() { instance = this; }