private void HandleItemCollection(LevelImp level) { ItemImp item; if (!level.MayCollectItem(this, out item)) { return; } switch (item.Type) { case ItemType.AdditionalBomb: PlacableBombCount++; CurrentPlacableBombCount++; break; case ItemType.AdditionalFireRange: BombExplosionRange++; break; case ItemType.AdditionalSpeed: Speed += SpeedIncrease; break; case ItemType.Punish: HandleCollectionPunish(); break; case ItemType.MaxRangeBomb: ActiveBombType = BombType.MaxRange; break; } CollectedItems.Add(item.Type); item.Collect(); }
public void Start() { Instance = this; Orders = CSVParser.ParseGrid(orders, (value, x, y) => new OrderProperties(value)); if (rackSetup == null) { SetupRacks(null, CreateRandomItemVariation); } else { SetupRacks(CSVParser.ParseGrid(rackSetup, (value, x, y) => value), CreateItemVariationFromItemGrid); } CollectedItems.Add(new List <CollectedItem>()); var webComObject = GameObject.FindGameObjectWithTag(Tags.WebComTag); if (webComObject != null) { webComponent = webComObject.GetComponent <WebCom>(); if (webComponent == null) { Debug.LogWarning("Cannot resolve WebCom component"); } else { // consume any time remaining from the last time a session was run // ie if the user aborts the game, we keep use of the last order sent to estimate // when the game should start. This time is kept in the web component and consumed // one time by the game state. TimeRemaining = Math.Max(0, maxTimeSeconds - webComponent.ConsumeSessionTime()); Debug.Log("Webcom found using user token " + webComponent.UserToken); } } else { Debug.LogWarning("Cannot resolve WebCom object"); TimeRemaining = maxTimeSeconds; } audioSource = GetComponent <AudioSource>(); State = GameStateComponentState.CountDown; }
public void OnOrderCompleted() { if (CurrentOrderListIndex < Orders.Count) { if (webComponent != null) { foreach (var collectedItem in _pickedupItems.Values) { // missed items have a negative position + (-1,-1) // this way we can still figure out where the item comes from collectedItem.pos = -(collectedItem.pos) + Vector2Int.one * -1; CollectedItems[CurrentOrderListIndex].Add(collectedItem); } webComponent.PostOrder(CollectedItems[CollectedItems.Count - 1], maxTimeSeconds - TimeRemaining); } else { Debug.LogWarning("no webcomponent defined, cannot send messages to server."); } foreach (var pickedUpItem in _pickedupItems.Keys) { GameObject.Destroy(pickedUpItem); } _pickedupItems.Clear(); TryToPlaySound(soundList.nextOrder); CollectedItems.Add(new List <CollectedItem>()); CurrentOrderLine = 0; } CurrentOrderListIndex++; if (CurrentOrderListIndex >= Orders.Count) { CurrentOrderLine = -1; Debug.Log("No more orders to collect..."); } }
private void LoadCollectedItems(List <MTConnectDevices.DataItem> dataItems) { var newItems = new List <CollectedItem>(); foreach (var dataItem in dataItems) { var item = new CollectedItem(dataItem); newItems.Add(item.Copy()); } foreach (var newItem in newItems) { if (!CollectedItems.ToList().Exists(x => x.Id == newItem.Id)) { CollectedItems.Add(newItem); } } foreach (var item in CollectedItems) { if (!newItems.Exists(x => x.Id == item.Id)) { CollectedItems.Remove(item); } } CollectedItems.SupressNotification = true; CollectedItems.Sort(); CollectedItems.SupressNotification = false; foreach (Controls.Event ev in events) { foreach (Controls.CaptureItem ci in ev.CaptureItems) { Dispatcher.BeginInvoke(new Action <Controls.CaptureItem>(CaptureItem_UpdateCollectedLink), priority, new object[] { ci }); } } }
//create a method to add one of the user's collected items to the list CollectedItems //then remove it from NotCollectedItems public void AddCollectedItem(string itemName) { CollectedItems.Add(itemName); NotCollectedItems.Remove(itemName); }