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: ");
    }
示例#2
0
 // 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;
 }
示例#3
0
 // 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);
     }
 }
示例#4
0
    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: ");
    }
示例#5
0
    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: ");
    }
示例#6
0
    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: ");
    }
示例#7
0
    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: ");
    }
示例#8
0
 // 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);
 }
示例#9
0
 // Use this for initialization
 void Start()
 {
     instance = this;
 }