// adds roller coaster cart reference to roller coaster controller and rc portal public void AddCartReference(RollerCoasterCart _rollerCoasterCart) { rollerCoasterCart = _rollerCoasterCart; rollerCoasterController.AddCartReference(rollerCoasterCart); rcCartPortal.AddCartReference(rollerCoasterCart); // add graph reph to cart rollerCoasterCart.AddGraphReference(graphCreator); if (trackIsComplete) { rollerCoasterCart.TrackIsComplete(true); } }
// updates list of items that are currently addable private void updateAddableList() { // always clear list addableList = new List <RollerCoasterItem.RCItemType>(); if (rollerCoasterCart) { rollerCoasterCart.TrackIsComplete(false); } trackIsComplete = false; // if empty, only start hill an be added if (rcItemList.Count == 0) { addableList.Add(itemTypeHill); return; } // Special Case for cart: if (!cartHasBeenAdded) { addableList.Add(itemTypeCart); } // *** Main Case 1: Adding looping or hill after start hill *** // start hill -> next can be anything if (rcItemList.Count == 1) { addableList.Add(itemTypeHill); addableList.Add(itemTypeBankedCurve10); addableList.Add(itemTypeBankedCurve15); addableList.Add(itemTypeBankedCurve20); addableList.Add(itemTypeLooping); return; } // start hill + looping || hill -> next must be banked curve if (rcItemList.Count == 2 && isHillOrLooping(rcItemList[1])) { addableList.Add(itemTypeBankedCurve10); addableList.Add(itemTypeBankedCurve15); addableList.Add(itemTypeBankedCurve20); return; } // start hill + looping|| hill + banked curved -> next can't be banked curve if (rcItemList.Count == 3 && isHillOrLooping(rcItemList[1]) && isAnyBankedCurve(rcItemList[2])) { addableList.Add(itemTypeHill); addableList.Add(itemTypeLooping); return; } // start hill + looping|| hill + banked curved + looping || hill -> next can't be banked curve if (rcItemList.Count == 4 && isHillOrLooping(rcItemList[1]) && isAnyBankedCurve(rcItemList[2]) && isHillOrLooping(rcItemList[3])) { addableList.Add(itemTypeHill); addableList.Add(itemTypeLooping); return; } // start hill + looping|| hill + banked curved + looping || hill + looping || hill + looping // -> next must be banked curve of same radius as the first one if (rcItemList.Count == 5 && isHillOrLooping(rcItemList[1]) && isAnyBankedCurve(rcItemList[2]) && isHillOrLooping(rcItemList[3])) { addableList.Add(rcItemList[2]); return; } // if we have 6 items, no more items can be added if (rcItemList.Count == 6) { if (rollerCoasterCart) { rollerCoasterCart.TrackIsComplete(true); } trackIsComplete = true; return; } // *** Main Case 2: Adding banked curve directly after start hill *** // start hill + banked curve -> next can't be banked curve if (rcItemList.Count == 2 && isAnyBankedCurve(rcItemList[1])) { addableList.Add(itemTypeHill); addableList.Add(itemTypeLooping); return; } // start hill + banked curve + looping || hill -> next must be banked curve of same radius as the first one if (rcItemList.Count == 3 && isAnyBankedCurve(rcItemList[1]) && isHillOrLooping(rcItemList[2])) { addableList.Add(rcItemList[1]); return; } // if we have 4 and already two banked curves, no more items can be added if (rcItemList.Count == 4 && isAnyBankedCurve(rcItemList[1]) && isHillOrLooping(rcItemList[2]) && isAnyBankedCurve(rcItemList[3])) { if (rollerCoasterCart) { rollerCoasterCart.TrackIsComplete(true); } trackIsComplete = true; return; } }