public override Compiler.Variable runFunction(Compiler.Scope currentScope, Compiler.Variable[] inputParas, int lineNumber) { GameObject currentCar = CarQueue.GetFirstCar(); if (currentCar == null) { PMWrapper.RaiseError(lineNumber, "Hittade inget tåg att tömma. "); } UnloadableItem[] itemsToUnload = currentCar.GetComponentsInChildren <UnloadableItem>(); if (itemsToUnload.Length == 0) { PMWrapper.RaiseError(lineNumber, "Kan inte tömma ett tomt tåg. Kom ihåg att köra fram nästa tåg innan du tömmer igen."); } foreach (UnloadableItem item in itemsToUnload) { if (item != null) { item.IsUnloading = true; } } GameObject.FindGameObjectWithTag("SceneController").GetComponent <SceneController1_3>().carsUnloaded += 1; return(new Compiler.Variable()); }
public override Variable runFunction(Scope currentScope, Variable[] inputParas, int lineNumber) { GameObject car = CarQueue.GetFirstCar(); if (car == null) { PMWrapper.RaiseError(lineNumber, "Kan inte hitta något att scanna."); } Scanner scanner = Scanner.Instance; scanner.Scan(car); int lampCount = 0; foreach (Transform child in car.transform) { if (child.CompareTag("Lamp")) { lampCount++; } } scanner.SetDisplayText(lampCount); return(new Variable("lampCount", lampCount)); }
public override Variable runFunction(Scope currentScope, Variable[] inputParas, int lineNumber) { int batteryLevel = CarQueue.GetFirstCar().GetComponent <CarInfo>().BatteryLevel; ChargeStation.Instance.CheckBattery(batteryLevel); return(new Variable("BatteryLevel", batteryLevel)); }
public override Variable runFunction(Scope currentScope, Variable[] inputParas, int lineNumber) { SortedQueue.ForwardQueue.Add(CarQueue.GetFirstCar()); CarQueue.DriveQueueForward(); CarQueue.DriveFirstCarStraight(); return(new Variable()); }
public override Variable runFunction(Scope currentScope, Variable[] inputParas, int lineNumber) { GameObject firstCar = CarQueue.GetFirstCar(); Scanner scanner = Scanner.Instance; scanner.Scan(firstCar); Dictionary <string, int> typesFound = new Dictionary <string, int>(); string type = ""; foreach (Transform t in firstCar.transform) { if (t.CompareTag("Palm")) { type = "palmer"; } else if (t.CompareTag("Table")) { type = "bord"; } else if (t.CompareTag("Chair")) { type = "stolar"; } else if (t.CompareTag("Lamp")) { type = "lampor"; } else if (t.CompareTag("Tree")) { type = "granar"; } if (type.Length > 0) { typesFound[type] = 1; } } if (typesFound.Count > 1) { throw new Exception("There are more than one type of items in current car. Can not unambiguously decide item type."); } scanner.SetDisplayText(type); return(new Variable("type", type)); }
public override Variable runFunction(Scope currentScope, Variable[] inputParas, int lineNumber) { GameObject car = CarQueue.GetFirstCar(); Scanner scanner = Scanner.Instance; scanner.Scan(car); int tableCount = 0; foreach (Transform child in car.transform) { if (child.CompareTag("Table")) { tableCount++; } } scanner.SetDisplayText(tableCount); return(new Variable("tablecount", tableCount)); }
private void SetCarCharged() { var carInfo = CarQueue.GetFirstCar().GetComponent <CarInfo>(); int chargeBound = LevelController.CaseData.chargeBound; if (carInfo.HasBeenCharged) { return; } if (carInfo.StartBatteryLevel < chargeBound) { SceneController2_1.CorrectlyCharged++; } else { if (carInfo.StartBatteryLevel != 100) { SceneController2_1.FalselyCharged++; } } carInfo.HasBeenCharged = true; }
public void ChargeBattery() { currentCarInfo = CarQueue.GetFirstCar().GetComponent <CarInfo>(); isRasingWalls = true; }