// Use this for initialization void Start() { gridSpawner = GameObject.FindGameObjectWithTag("Spawner").GetComponent <SpawnGrid>(); grid = gridSpawner.grid; fuelBehaviour = GameObject.FindGameObjectWithTag("FuelBar").GetComponent <FuelBehaviour>(); points = fuelBehaviour.dollars; }
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); }
/* * Reduces fuel available to the player on each movement. */ private void FuelConsume(FuelBehaviour fuelBar) { if (this.transform.position.y != 1) { fuelBar.fuel--; fuelBar.UpdateFuel(); } }
/// <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); }
/** * 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"); } }
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 }
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); }
// Use this for initialization void Start() { fuelBehaviour = GameObject.FindGameObjectWithTag("FuelBar").GetComponent <FuelBehaviour>(); }
// Use this for initialization void Start() { fuelBar = GameObject.FindGameObjectWithTag("FuelBar").GetComponent <FuelBehaviour>(); grid = GameObject.FindGameObjectWithTag("Spawner").GetComponent <SpawnGrid>(); refuel = GameObject.FindGameObjectWithTag("Refuel"); }