示例#1
0
 // Use this for initialization
 void Start()
 {
     gridSpawner   = GameObject.FindGameObjectWithTag("Spawner").GetComponent <SpawnGrid>();
     grid          = gridSpawner.grid;
     fuelBehaviour = GameObject.FindGameObjectWithTag("FuelBar").GetComponent <FuelBehaviour>();
     points        = fuelBehaviour.dollars;
 }
示例#2
0
    public Vector3 TestMovement(string direction, GameObject go)
    {
        Vector3       result = new Vector3(0, 0, 0);
        FuelBehaviour fb     = go.GetComponent <FuelBehaviour>();

        fb.fuel = 2;
        if (direction == "up")
        {
            Movement(new Vector3(0, 1, 0), Quaternion.Euler(0, 0, 0), fb);
            result = this.transform.position;
        }
        else if (direction == "down")
        {
            Movement(new Vector3(0, -1, 0), Quaternion.Euler(0, 0, 0), fb);
            result = this.transform.position;
        }
        else if (direction == "left")
        {
            Movement(new Vector3(-1, 0, 0), Quaternion.Euler(0, 0, -90), fb);
            result = this.transform.position;
        }
        else if (direction == "right")
        {
            Movement(new Vector3(1, 0, 0), Quaternion.Euler(0, 0, 90), fb);
            result = this.transform.position;
        }
        return(result);
    }
示例#3
0
 /*
  * Reduces fuel available to the player on each movement.
  */
 private void FuelConsume(FuelBehaviour fuelBar)
 {
     if (this.transform.position.y != 1)
     {
         fuelBar.fuel--;
         fuelBar.UpdateFuel();
     }
 }
示例#4
0
    /// <summary>
    /// Dynamically create digger object for use in integration testing.
    /// </summary>
    /// <returns>The fake player.</returns>
    private static GameObject TestDigger()
    {
        GameObject go = new GameObject();

        go.AddComponent <DiggerControl>();
        FuelBehaviour fb = go.AddComponent <FuelBehaviour>();

        fb.fuelBar   = go.AddComponent <Text>();
        fb.fuel      = 100;
        fb.dollarBar = new GameObject().AddComponent <Text>();
        fb.dollars   = 100;
        return(go);
    }
示例#5
0
 /**
  * Controls movement of the player sprite.
  * Standard Controls (arrows + wasd). Only moves one block per press
  */
 private void Movement(Vector3 position, Quaternion rotation, FuelBehaviour fuelbar)
 {
     if (position != null)
     {
         this.transform.rotation  = rotation;
         this.transform.position += position;
         FuelConsume(fuelbar);
     }
     else
     {
         Debug.Log("not");
     }
 }
示例#6
0
    public IEnumerator MovementConsumesFuel()
    {
        GameObject    digger  = IntegrationTestScript.TestDigger();
        DiggerControl control = digger.GetComponent <DiggerControl>();
        FuelBehaviour fb      = digger.GetComponent <FuelBehaviour>();

        fb.fuel = 2;
        yield return(null);

        var initialFuel = fb.fuel;

        // To do this, move down twice and ensure that fuel has been consumed.
        control.TestMovement("down", digger);
        Assert.AreEqual(fb.fuel, initialFuel - 1);
        // Use the Assert class to test conditions.
        // yield to skip a frame
    }
示例#7
0
    public IEnumerator CannotBuyWithoutDollars()
    {
        GameObject    digger = IntegrationTestScript.TestDigger();
        FuelBehaviour fb     = digger.GetComponent <FuelBehaviour>();

        fb.dollars = 0;
        yield return(null);

        fb.UpdateDollars(10);
        int initialDollars = fb.dollars;

        Assert.AreEqual(10, initialDollars);
        fb.Refuel();
        Assert.AreEqual(fb.dollars, initialDollars - 5);
        fb.Refuel();
        Assert.AreEqual(fb.dollars, 0);
        int endingFuel = fb.fuel;

        fb.Refuel();
        Assert.AreEqual(fb.dollars, 0);
        Assert.AreEqual(fb.fuel, endingFuel);
    }
示例#8
0
文件: Refuel.cs 项目: Qw3rtyone/ACME
 // Use this for initialization
 void Start()
 {
     fuelBehaviour = GameObject.FindGameObjectWithTag("FuelBar").GetComponent <FuelBehaviour>();
 }
示例#9
0
 // Use this for initialization
 void Start()
 {
     fuelBar = GameObject.FindGameObjectWithTag("FuelBar").GetComponent <FuelBehaviour>();
     grid    = GameObject.FindGameObjectWithTag("Spawner").GetComponent <SpawnGrid>();
     refuel  = GameObject.FindGameObjectWithTag("Refuel");
 }