private void TryInteract() { if (!status.isHolding) { foreach (int objId in detectedObjectList) { ObjectInfo info = GameManager.instance.GetObjectInfo(objId); Debug.Log(info.Name + ":" + info.IsInteractable.ToString()); if (!info.IsInteractable) { continue; } if (info.Properties.Contains(ObjectProperty.Switch)) { info.GetComponent <ISwitch>().Switch(); return; } if (info.Properties.Contains(ObjectProperty.Portable)) { info.GetComponent <Portable>().PickUp(identity, transform); status.HoldObject(objId); return; } } } else { foreach (int objId in detectedObjectList) { ObjectInfo info = GameManager.instance.GetObjectInfo(objId); if (info.Properties.Contains(ObjectProperty.Container)) { Debug.Log("Container meet " + GameManager.instance.GetObjectInfo(status.holdingObjectId)); if (info.GetComponent <Container>().PutIn(status.holdingObjectId)) { GameManager.instance.GetObjectInfo(status.holdingObjectId).IsInteractable = false; GameManager.instance.GetObjectInfo(status.holdingObjectId).gameObject.SetActive(false); status.ReleaseObject(); return; } } } GameManager.instance.GetObjectInfo(status.holdingObjectId).GetComponent <Portable>().PutDown(identity); status.ReleaseObject(); return; } }
// Update is called once per frame void Update() { primary = GameObject.FindGameObjectWithTag("Player").GetComponent <InputManager>().primary; if (primary != null) { objectInfo = primary.GetComponent <ObjectInfo>(); } if (primary != null) { if (objectInfo.maxEnergy <= 0) { EB.gameObject.SetActive(false); } unitName.text = objectInfo.GetComponent <ObjectInfo>().objectName; health.text = "HP: " + objectInfo.GetComponent <ObjectInfo>().health; energy.text = "EP: " + objectInfo.GetComponent <ObjectInfo>().energy; HB.maxValue = objectInfo.maxHealth; HB.value = objectInfo.health; EB.maxValue = objectInfo.maxEnergy; EB.value = objectInfo.energy; patk.text = "PATK: " + objectInfo.GetComponent <ObjectInfo>().patk; pdef.text = "PDEF: " + objectInfo.GetComponent <ObjectInfo>().pdef; eatk.text = "PDEF: " + objectInfo.GetComponent <ObjectInfo>().eatk; edef.text = "EDEF: " + objectInfo.GetComponent <ObjectInfo>().edef; rank.text = "Rank: " + objectInfo.GetComponent <ObjectInfo>().rank; kills.text = "Kills: " + objectInfo.GetComponent <ObjectInfo>().kills; primary.GetComponentInChildren <Camera>().enabled = true; //iconCam.enabled = true; InfoPanel.alpha = 1; InfoPanel.blocksRaycasts = true; InfoPanel.interactable = true; } else { InfoPanel.alpha = 0; InfoPanel.blocksRaycasts = false; InfoPanel.interactable = false; //primary.GetComponent<Camera>().enabled = false; //iconCam.enabled = false; } }
public bool EnterGuess(ObjectInfo obj, int selected) { ObjectInfo.OptionData selection = obj.Options[selected]; if (selection.isCorrect) { Options[selected].GetComponent<TextMesh>().color = new Color(0f, 1f, 0f); obj.GetComponent<AudioSource>().Play(); } else { Options[selected].GetComponent<TextMesh>().color = new Color(1f, 0f, 0f); } return selection.isCorrect; }
public static void Prefix(SavedCustomObject save, ObjectInfo CreateFromThis) { /* * CustomData structure: * - CustomComponent.UniqueName * - Outputs.On[] * - Fields[] */ List <object> saveData = new List <object>(); var customComponent = CreateFromThis.GetComponent <UpdateHandler>(); CircuitOutput[] outputs = CreateFromThis.GetComponentsInChildren <CircuitOutput>(); if (customComponent.Component == null) { MDebug.WriteLine("!!customComponent.Component IS NULL!! NAME: " + customComponent.ComponentName); if (customComponent.ComponentName != null) { if (ComponentRegistry.Registry.TryGetValue(customComponent.ComponentName, out var comp)) { customComponent.Component = comp; } else { MDebug.WriteLine("!!MISING COMPONENT: " + customComponent.ComponentName); } } else { MDebug.WriteLine("!!customComponent.ComponentName IS ALSO NULL!! ALLOW ME TO JUMP OFF A CLIFF"); return; } } saveData.Add(customComponent.ComponentName); saveData.Add(outputs.Select(o => o.On).ToArray()); saveData.AddRange(GetSaveThisFields(customComponent)); save.CustomData = saveData.ToArray(); }
static void Postfix(ObjectInfo worldsave, ref SavedObjectV2 __result) { var netObj = worldsave.GetComponent <NetObject>(); if (netObj != null) { if (__result.Children == null) { __result.Children = new SavedObjectV2[0]; } SavedObjectV2[] newChildren = new SavedObjectV2[__result.Children.Length + 1]; Array.Copy(__result.Children, 0, newChildren, 1, __result.Children.Length); newChildren[0] = new SavedNetObject(netObj.NetID); __result.Children = newChildren; } }
private void Update() { if (currentInfo == null) { Array.ForEach(buttons, a => a.gameObject.SetActive(false)); } else { int count = currentInfo.Abilities.Length; for (int i = 0; i < buttons.Length; i++) { if (i < count) { buttons[i].gameObject.SetActive(true); switch (currentInfo.Abilities[i].Type) { case AbilityType.Spawn: buttons[i].onClick.RemoveAllListeners(); Spawner spawner = currentInfo.GetComponent <Spawner>(); int j = i; buttons[i].onClick.AddListener(() => { spawner.SpawnUnit(currentInfo.Abilities[j].Argument); }); break; } } else { buttons[i].gameObject.SetActive(false); } } } }
public static SavedObjectV2 CreateSavedObjectFrom(ObjectInfo worldsave) { //SavedObjectV2 newsavedobject = SaveManager.ObjectTypeToSavedObjectType(save.ObjectType); SavedObjectV2 newsavedobject = null; switch (worldsave.ComponentType) { case ComponentType.CustomObject: newsavedobject = new SavedCustomObject(); CreateCustomSavedObject((SavedCustomObject)newsavedobject, worldsave); break; case ComponentType.CircuitBoard: CircuitBoard board = worldsave.GetComponent <CircuitBoard>(); newsavedobject = new SavedCircuitBoard { x = board.x, z = board.z, color = board.GetBoardColor }; break; case ComponentType.Wire: InputInputConnection IIConnection = worldsave.GetComponent <InputInputConnection>(); newsavedobject = new SavedWire { InputInput = IIConnection, length = worldsave.transform.localScale.z }; break; case ComponentType.Button: newsavedobject = new SavedButton(); break; case ComponentType.PanelButton: newsavedobject = new SavedPanelButton(); break; case ComponentType.Delayer: Delayer delayer = worldsave.GetComponent <Delayer>(); newsavedobject = new SavedDelayer { OutputOn = delayer.Output.On, DelayCount = delayer.DelayCount }; break; case ComponentType.Display: Display display = worldsave.GetComponentInChildren <Display>(); newsavedobject = new SavedDisplay { Color = display.DisplayColor }; break; case ComponentType.PanelDisplay: Display paneldisplay = worldsave.GetComponentInChildren <Display>(); newsavedobject = new SavedPanelDisplay { Color = paneldisplay.DisplayColor }; break; case ComponentType.Inverter: Inverter notgate = worldsave.GetComponent <Inverter>(); newsavedobject = new SavedInverter { OutputOn = notgate.Output.On }; break; case ComponentType.Label: Label label = worldsave.GetComponent <Label>(); newsavedobject = new SavedLabel { text = label.text.text, FontSize = label.text.fontSize }; break; case ComponentType.PanelLabel: Label panellabel = worldsave.GetComponent <Label>(); newsavedobject = new SavedPanelLabel { text = panellabel.text.text, FontSize = panellabel.text.fontSize }; break; case ComponentType.Switch: // SWITCH-F*****G-CEPTION Switch circuitswitch = worldsave.GetComponentInChildren <Switch>(); newsavedobject = new SavedSwitch { on = circuitswitch.On }; break; case ComponentType.PanelSwitch: Switch panelswitch = worldsave.GetComponentInChildren <Switch>(); newsavedobject = new SavedPanelSwitch { on = panelswitch.On }; break; case ComponentType.Peg: newsavedobject = new SavedPeg(); break; case ComponentType.ThroughPeg: newsavedobject = new SavedThroughPeg(); break; case ComponentType.Blotter: Blotter blotter = worldsave.GetComponent <Blotter>(); newsavedobject = new SavedBlotter { OutputOn = blotter.Output.On }; break; case ComponentType.ThroughBlotter: Blotter throughblotter = worldsave.GetComponent <Blotter>(); newsavedobject = new SavedThroughBlotter { OutputOn = throughblotter.Output.On }; break; case ComponentType.ColorDisplay: newsavedobject = new SavedColorDisplay(); break; case ComponentType.PanelColorDisplay: newsavedobject = new SavedPanelColorDisplay(); break; case ComponentType.Noisemaker: Noisemaker noisemaker = worldsave.GetComponentInChildren <Noisemaker>(); newsavedobject = new SavedNoisemaker { ToneFrequency = noisemaker.ToneFrequency }; break; case ComponentType.SnappingPeg: newsavedobject = new SavedSnappingPeg(); break; case ComponentType.Mount: newsavedobject = new SavedMount(); break; case ComponentType.VerticalSnappingPeg: newsavedobject = new SavedVerticalSnappingPeg(); break; case ComponentType.none: Debug.LogError("BIG ERROR tried to save a component with no type!"); break; } newsavedobject.LocalPosition = worldsave.transform.localPosition; newsavedobject.LocalEulerAngles = worldsave.transform.localEulerAngles; if (newsavedobject.CanHaveChildren) { newsavedobject.Children = FindChildSaves(worldsave); } return(newsavedobject); }