/*--------------------------------------------------- * each frame when object details are being displayed in the Inspector: * * offer a drop down list * * base on the item selected in the list * call the appropriate method (i.e. the one corresponding to the type selected) * * finally, store back any changes to GameObject 'ApplyModifiedProperties()' */ public override void OnInspectorGUI() { serializedObject.Update(); string[] pickUpCategories = TypesToStringArray(); pickUpType.enumValueIndex = EditorGUILayout.Popup("PickUp TYPE: ", pickUpType.enumValueIndex, pickUpCategories); PickUp.PickUpType type = (PickUp.PickUpType)pickUpType.enumValueIndex; switch (type) { case PickUp.PickUpType.Health: InspectorGUI_HEALTH(); break; case PickUp.PickUpType.Key: InspectorGUI_KEY(); break; case PickUp.PickUpType.Star: default: InspectorGUI_STAR(); break; } serializedObject.ApplyModifiedProperties(); }
//-------------------- // add given 'pickup' objects to our Dictionary public void Add(PickUp pickup) { // get the type of this pickup object PickUp.PickUpType type = pickup.type; // init total to zerpo int oldTotal = 0; // IF we can find this type in the Dictionary // then set 'oldTotal' to the associated value if (items.TryGetValue(type, out oldTotal)) { // add 1 to existing total (since we just picked one up) items[type] = oldTotal + 1; } else { // if we could not find the type key in the Dictionary // then add new item, with total 1 (since we just picked one up) items.Add(type, 1); } // tell the display object to update the UI display with the new totals in 'items' Dictionary playerInventoryDisplay.OnChangeInventory(items); }
public PickUpGen(CoreEngine c, Vector3 p, PickUp.PickUpType t) { core = c; pos = p; itemType = t; held = null; genTime = 300; }
public PickUpGen(CoreEngine c, Vector3 p, PickUp.PickUpType t) { core = c; pos = p; itemType = t; held = null; genTime = 300; }
public void Add(PickUp pickup) { PickUp.PickUpType type = pickup.type; int oldTotal = 0; if (items.TryGetValue(type, out oldTotal)) { items[type] = oldTotal + 1; } else { items.Add(type, 1); } playerInventoryDisplay.OnChangeInventory(items); }
public void genPickUp(PickUp.PickUpType type) { held = new PickUp(pos + new Vector3(0, 50, 0), itemType, this); core.physicsEngine.updateCollisionCellsFor(held); }