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(); }
void SaveCaptureItems(CaptureItem ci, Event e, DataTable dt) { string adr = "/GeneratedData/GeneratedEvents/Event||" + e.id.ToString("00") + "/Capture/Item"; int id = DataTable_Functions.TrakHound.GetUnusedAddressId(adr, dt); adr = adr + "||" + id.ToString("00"); ci.id = id; // Save Root string attr = ""; attr += "id||" + ci.id.ToString("00") + ";"; attr += "name||" + ci.name.Replace(' ', '_').ToLower() + ";"; string link = ci.link; List <CollectedItem> linkitems = CollectedItems.ToList(); CollectedItem dataitem = linkitems.Find(x => x.Display == link); if (dataitem != null) { link = dataitem.Id; } attr += "link||" + link + ";"; DataTable_Functions.UpdateTableValue(dt, "address", adr, "attributes", attr); }
void CaptureItem_UpdateCollectedLink(Controls.CaptureItem item) { Page.CollectedItem ci = CollectedItems.ToList().Find(x => x.Id == item.link_COMBO.Text); if (ci != null) { item.link_COMBO.Text = ci.Display; } }
public void ReSpawn() { IsAlive = true; Speed = BaseSpeed; BombExplosionRange = 1; PlacableBombCount = 1; CurrentPlacableBombCount = PlacableBombCount; WalkDirection = Vector2.Zero; Direction = FigureDirection.Down; CollectedItems.Clear(); ActiveBombType = BombType.Normal; FigureController?.ResetInputs(); }
void SaveTrigger(Trigger t, Value v, Event e, DataTable dt, string addressPrefix) { if (t.link != null && t.modifier != null) { string adr = addressPrefix + "/Trigger"; int id = DataTable_Functions.TrakHound.GetUnusedAddressId(adr, dt); adr = adr + "||" + id.ToString("00"); t.id = id; // Save Root string attr = ""; attr += "id||" + t.id.ToString("00") + ";"; string link = t.link; List <CollectedItem> linkitems = CollectedItems.ToList(); CollectedItem dataitem = linkitems.Find(x => x.Display == link); if (dataitem != null) { link = dataitem.Id; } attr += "link||" + link + ";"; attr += "link_type||" + t.linkType + ";"; if (t.modifier != null) { switch (t.modifier) { case "Not Equal To": attr += "modifier||" + "not" + ";"; break; case "Greater Than": attr += "modifier||" + "greater_than" + ";"; break; case "Less Than": attr += "modifier||" + "less_than" + ";"; break; case "Contains": attr += "modifier||" + "contains" + ";"; break; case "Contains Match Case": attr += "modifier||" + "contains_match_case" + ";"; break; case "Contains Whole Word": attr += "modifier||" + "contains_whole_word" + ";"; break; case "Contains Whole Word Match Case": attr += "modifier||" + "contains_whole_word_match_case" + ";"; break; } } attr += "value||" + t.value + ";"; DataTable_Functions.UpdateTableValue(dt, "address", adr, "attributes", attr); } }
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 allowing the user to remove an item previously on the list CollectedItems //then add it to NotCollectedItems public void RemoveCollectedItem(string itemName) { CollectedItems.Remove(itemName); NotCollectedItems.Add(itemName); }