//Step function returns whether is moves or not during the step. public EntityController.EntityStepData Step() { //wheel moving = toggleableScript.state; if (moving && wheelableScript.disbanded) { List <EntityController.Entity> friends = LookForFriends(); friends.Add(entityScript.selfEntity); Debug.Log("initiating car"); Vector3 position = transform.position; GameObject gridObject = entityController.AddEntity(position.x, position.y, "car", false, friends).obj; if (gridObject == null) { Debug.Log("car not loaded"); } toggleableScript.Toggle(); Debug.Log("finished initiating car"); } //will move whenever active return(new EntityController.EntityStepData(moving, false)); }
private void CollectCoal() { int tileID = terrainController.GetTileAtPosition(transform.position); if (tileID == terrainController.GetTileID("coal")) { //we are on coal Vector2Int roundedPosition = new Vector2Int(Mathf.RoundToInt(transform.position.x), Mathf.RoundToInt(transform.position.y)); int tileData = terrainController.terrainArray.GetTileData(roundedPosition.x, roundedPosition.y); Tuple <int, int> mineData; if (tileData == -1) { mineData = MineResource(terrainController.coalResourceAmount, mineIncrementSize); } else { mineData = MineResource(tileData, mineIncrementSize); } if (mineData.Item1 == 0) { mineData = new Tuple <int, int>(-1, mineData.Item2); terrainController.terrainArray.Set(roundedPosition.x, roundedPosition.y, terrainController.GetTileID("dirt")); } terrainController.terrainArray.SetTileData(roundedPosition.x, roundedPosition.y, mineData.Item1); Debug.LogFormat("Mined {0} coal, leaving {1}", mineData.Item2, mineData.Item1); } else { Debug.LogFormat("Can't mine, we are on {0}", tileID); toggleableScript.Toggle(); } }