Skip to content

Commit

Permalink
Fix send units after start/restart
Browse files Browse the repository at this point in the history
  • Loading branch information
BabichMikhail committed May 6, 2018
1 parent c76cbca commit ebbb3b2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion Assets/Resources/scripts/MainController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public class MyIntTuple {

public class MainController : MonoBehaviour {
private List<RouterController> routerControllers = new List<RouterController>();
private float startedAt;

public GameObject mainTower;
public GameObject[] towers0;
Expand All @@ -28,6 +29,8 @@ private void Awake()

private void Start()
{
startedAt = Time.time;

var routeContainer = Container.GetInstance().GetRouteContainer();
var collider = mainTower.GetComponentInChildren<Collider>();
Debug.Assert(collider != null);
Expand Down Expand Up @@ -75,7 +78,7 @@ private void Update()

public void TryToSendUnit()
{
int now = (int)(Time.time * 1000);
int now = (int)((Time.time - startedAt) * 1000);
if (lastSendUnitTime + SEND_UNIT_INTERVAL < now && sendUnitsIndex < sendUnits.Count && sendUnits[sendUnitsIndex].first <= now) {
SendUnit(sendUnits[sendUnitsIndex].third);
--sendUnits[sendUnitsIndex].second;
Expand Down
2 changes: 1 addition & 1 deletion Assets/main.unity
Original file line number Diff line number Diff line change
Expand Up @@ -9849,7 +9849,7 @@ MonoBehaviour:
m_EditorClassIdentifier:
health: 10000
defeatMenu: {fileID: 1842057281}
gameMenu: {fileID: 0}
gameMenu: {fileID: 1963433602}
--- !u!1 &1674194213
GameObject:
m_ObjectHideFlags: 0
Expand Down

0 comments on commit ebbb3b2

Please sign in to comment.