public override void CheckForUtensil() { if (localCell.interactions.Count < limit) { GenericInteraction current = Interaction.GetCurrent(); localCell.SetPosition(transform.position + bottom); localCell.interactions.Add(current); current.SetSurfaceCell(localCell); buffer = new Vector3(0, transform.position.y / 2, 0); StartCoroutine(Interaction.DelayThePhysics(localCell.Position() + buffer, current)); } else { Debug.Log("Pan full"); //localCell.SetOccupied(true); } }
public static IEnumerator ArcPutDown(Transform fromPos, GenericInteraction inter, float dur) { float counter = 0; Quaternion q = Quaternion.Euler(0, Camera.main.transform.eulerAngles.y, 0); Vector3 toPos = inter.GetCell().transform.position; Vector3 start = fromPos.position; Vector3 arc = start + (toPos - start) / 2 + Vector3.up * .5f; float distance = Vector3.Distance(fromPos.position, toPos); //distance - vel=distance/time float time = distance / dur; while (counter < dur) { counter += Time.deltaTime; toPos = inter.GetCell().transform.position; Vector3 m1 = Vector3.Lerp(start, arc, counter / dur); Vector3 m2 = Vector3.Lerp(arc, toPos, counter / dur); fromPos.position = Vector3.Lerp(m1, m2, counter / dur); fromPos.rotation = Quaternion.Slerp(fromPos.rotation, q, counter / dur); yield return(null); } }
public static IEnumerator ArcPickUp(Transform fromPos, GenericInteraction inter, float dur) { float counter = 0; fromPos.rotation = guide.transform.rotation; Vector3 start = fromPos.position; Vector3 toPos = inter.GetCell().transform.position; Vector3 arc = start + (toPos - start) / 2 + Vector3.up * .5f; float distance = Vector3.Distance(fromPos.position, toPos); //distance - vel=distance/time float time = distance / dur; while (counter < dur) { counter += Time.deltaTime; toPos = inter.GetCell().transform.position + new Vector3(0, inter.transform.localScale.y / 2, 0); Vector3 m1 = Vector3.Lerp(start, arc, counter / dur); Vector3 m2 = Vector3.Lerp(arc, toPos, counter / dur); fromPos.position = Vector3.Lerp(m1, m2, counter / dur); yield return(null); } }
protected override void CheckCanPlace(RaycastHit hit, Interaction main) { DynamicCell cell = GetPosition(cells, hit.point); if (cell != null) //position is not taken { if (main.Currents().Count > 1) //if the player is holding more than one item { StartCoroutine(DelayedDrop(main.Currents(), cell, main)); } else { GenericInteraction current = main.Currents()[0]; AssignInteraction(current, cell); StartCoroutine(main.OnPutDown(current)); } } else { Debug.Log("This slot is taken!!"); } }
public override void OnLeftMouseButton(RaycastHit hit) { if (Interaction.IsHolding()) { GenericInteraction obj = Interaction.GetCurrent(); base.GetCellAndMove(hit); int timeToCook = 0; if (obj.tag == "Utensil") { Cell cell = obj.LocalCell(); if (cell.interactions.Count > 0) { timeToCook += obj.genericCookTime * cell.interactions.Count; } else { Debug.Log("Nothing in the pan!!"); } } Debug.Log(timeToCook); } }
protected override void CheckCanPlace(RaycastHit hit, Interaction main) { if (main.Currents().Count > 1 || main.Currents()[0].CompareTag(tag))//more than one object in hand { Debug.Log("Cant do that"); } else { DynamicCell cell = GetPosition(dynamicPositions, hit.point); if (cell != null) { GenericInteraction current = main.Currents()[0]; current.SetDesination(cell.transform.position); current.SetParent(this); current.SetCell(cell); localInteractions.Add(current); StartCoroutine(main.OnPutDown(current)); } else { Debug.Log("slot Taken"); } } }
/// <summary> /// Sets up Generic picker window /// </summary> private void SetGenericPicker(GenericPickerDetails details) { //close Node tooltip safety check GameManager.i.tooltipNodeScript.CloseTooltip("ModalGenericPicker.cs -> SetGenericPicker"); //open Generic picker bool errorFlag = false; CanvasGroup genericCanvasGroup; //set modal status GameManager.i.guiScript.SetIsBlocked(true); //activate main panel modalPanelObject.SetActive(true); //header activated only if text provided if (string.IsNullOrEmpty(details.textHeader) == false) { modalHeader.gameObject.SetActive(true); headerText.text = details.textHeader; } else { modalHeader.gameObject.SetActive(false); } //activate dialogue window modalPickerCanvas.gameObject.SetActive(true); modalGenericObject.SetActive(true); //confirm button should be switched off at the start buttonConfirm.gameObject.SetActive(false); //back button only switched on if it has a valid underlying eventType if (backReturnEvent == EventType.None) { buttonBack.gameObject.SetActive(false); } else { buttonBack.gameObject.SetActive(true); } //halt execution, until picker is processed, if indicated if (details.isHaltExecution == true) { GameManager.i.turnScript.haltExecution = true; } //canvasGroup.alpha = 100; //populate dialogue if (details != null) { if (details.arrayOfOptions.Length > 0) { //initialise data nodeIDSelected = details.nodeID; actorSlotIDSelected = details.actorSlotID; datapoint = details.data; optionIDSelected = -1; optionNameSelected = ""; //set help List <HelpData> listOfHelpData = GameManager.i.helpScript.GetHelpData(details.help0, details.help1, details.help2, details.help3); if (listOfHelpData != null && listOfHelpData.Count > 0) { buttonHelp.gameObject.SetActive(true); help.SetHelpTooltip(listOfHelpData, 150, 200); } else { buttonHelp.gameObject.SetActive(false); } //assign sprites, texts, optionID's and tooltips for (int i = 0; i < details.arrayOfOptions.Length; i++) { if (arrayOfGenericOptions[i] != null) { GenericInteraction interaction = arrayOfInteractions[i]; if (interaction != null) { //there are 'maxOptions' options but not all of them may be used if (details.arrayOfOptions[i] != null) { //get option canvas genericCanvasGroup = arrayOfGenericOptions[i].GetComponent <CanvasGroup>(); if (genericCanvasGroup != null) { //activate option arrayOfGenericOptions[i].SetActive(true); //populate data interaction.optionImage.sprite = details.arrayOfOptions[i].sprite; interaction.displayText.text = details.arrayOfOptions[i].text; interaction.imageInteraction.data.optionID = details.arrayOfOptions[i].optionID; interaction.imageInteraction.data.optionName = details.arrayOfOptions[i].optionName; interaction.imageInteraction.data.optionNested = details.arrayOfOptions[i].optionText; interaction.imageInteraction.data.actorSlotID = details.actorSlotID; //option Active or Not? if (details.arrayOfOptions[i].isOptionActive == true) { //activate option genericCanvasGroup.alpha = 1.0f; genericCanvasGroup.interactable = true; interaction.imageInteraction.isActive = true; } else { //deactivate option genericCanvasGroup.alpha = 0.25f; genericCanvasGroup.interactable = false; interaction.imageInteraction.isActive = false; } //tooltip -> Image GenericTooltipUI tooltipImage = arrayOfImageTooltips[i]; if (details.arrayOfImageTooltips[i] != null) { tooltipImage.tooltipHeader = details.arrayOfImageTooltips[i].textHeader; tooltipImage.tooltipMain = details.arrayOfImageTooltips[i].textMain; tooltipImage.tooltipDetails = details.arrayOfImageTooltips[i].textDetails; } else { //default values tooltipImage.tooltipHeader = ""; tooltipImage.tooltipMain = ""; tooltipImage.tooltipDetails = ""; } //tooltip -> Text GenericTooltipUI tooltipText = arrayOfTextTooltips[i]; if (details.arrayOfTextTooltips[i] != null) { tooltipText.tooltipHeader = details.arrayOfTextTooltips[i].textHeader; tooltipText.tooltipMain = details.arrayOfTextTooltips[i].textMain; tooltipText.tooltipDetails = details.arrayOfTextTooltips[i].textDetails; } else { //default values tooltipText.tooltipHeader = ""; tooltipText.tooltipMain = ""; tooltipText.tooltipDetails = ""; } } else { Debug.LogError(string.Format("Invalid genericCanvasGroup for arrayOfGenericOptions[{0}]", i)); } } else { arrayOfGenericOptions[i].SetActive(false); } } else { //error -> Null Interaction data Debug.LogError(string.Format("Invalid arrayOfGenericOptions[\"{0}\"] genericData (Null)", i)); errorFlag = true; break; } } else { //error -> Null array Debug.LogError(string.Format("Invalid arrayOfGenericOptions[\"{0}\"] (Null)", i)); errorFlag = true; break; } } //register return event for reference once user confirms a choice defaultReturnEvent = details.returnEvent; } } else { //error -> null parameter Debug.LogError("Invalid GenericPickerDetails (Null)"); errorFlag = true; } //if a problem then generate an outcome window instead if (errorFlag == true) { modalPickerCanvas.gameObject.SetActive(false); /*modalGenericObject.SetActive(false);*/ //create an outcome window to notify player ModalOutcomeDetails outcomeDetails = new ModalOutcomeDetails(); outcomeDetails.textTop = "There has been a SNAFU"; outcomeDetails.textBottom = "Heads, toes and other limbswill be removed"; outcomeDetails.side = details.side; EventManager.i.PostNotification(EventType.OutcomeOpen, this, outcomeDetails, "ModalGenericPicker.cs -> SetGenericPicker"); } //all good, generate else { //texts topText.text = details.textTop; middleText.text = details.textMiddle; bottomText.text = details.textBottom; //set game state ModalStateData package = new ModalStateData(); package.mainState = ModalSubState.GenericPicker; package.pickerState = details.subState; GameManager.i.inputScript.SetModalState(package); Debug.LogFormat("[UI] ModalGenericPicker.cs -> SetGenericPicker{0}", "\n"); } }
private void SubInitialiseSessionStart() { maxOptions = GameManager.i.guiScript.maxPickerOptions; Debug.Assert(maxOptions == 3, "Invalid maxOptions (must be 3)"); //arrays arrayOfInteractions = new GenericInteraction[maxOptions]; arrayOfImageTooltips = new GenericTooltipUI[maxOptions]; arrayOfTextTooltips = new GenericTooltipUI[maxOptions]; //confirm button event buttonConfirmInteraction = buttonConfirm.GetComponent <ButtonInteraction>(); if (buttonConfirmInteraction != null) { buttonConfirmInteraction.SetButton(EventType.ConfirmGenericChoice); } else { Debug.LogError("Invalid buttonInteraction Confirm (Null)"); } //cancel button event buttonCancelInteraction = buttonCancel.GetComponent <ButtonInteraction>(); if (buttonCancelInteraction != null) { buttonCancelInteraction.SetButton(EventType.CancelButtonGeneric); } else { Debug.LogError("Invalid buttonInteraction Confirm (Null)"); } //help button help = buttonHelp.GetComponent <GenericHelpTooltipUI>(); if (help == null) { Debug.LogError("Invalid help script (Null)"); } //Back button event (default -> can be set dynamically using 'SetBackButton' method buttonBackInteraction = buttonBack.GetComponent <ButtonInteraction>(); if (buttonBackInteraction != null) { buttonBackInteraction.SetButton(EventType.BackButtonGeneric); } else { Debug.LogError("Invalid buttonBackInteraction (Null)"); } backReturnEvent = EventType.None; //tooltips for (int i = 0; i < maxOptions; i++) { //interaction GenericInteraction interaction = arrayOfGenericOptions[i].GetComponent <GenericInteraction>(); if (interaction != null) { arrayOfInteractions[i] = interaction; //tooltip image GenericTooltipUI tooltipImage = interaction.imageTooltip; if (tooltipImage != null) { arrayOfImageTooltips[i] = tooltipImage; } else { Debug.LogErrorFormat("Invalid tooltipImage (Null) for arrayOfInteractions[{0}]", i); } //tooltip text GenericTooltipUI tooltipText = interaction.textTooltip; if (tooltipText != null) { arrayOfTextTooltips[i] = tooltipText; } else { Debug.LogErrorFormat("Invalid tooltipText (Null) for arrayOfInteractions[{0}]", i); } } else { Debug.LogErrorFormat("Invalid interaction (Null) for arrayOfGenericOptions[{0}]", i); } } }
private void SpawnVIPSelections(CharacterMaster master) { Shuffle(characterAllies); int numSpawns = characterAllies.Count; float radius = Mathf.Max(30f, (numSpawns + 1) * 3f); Vector3 center = getTransform(master.GetBody()).position; // Disable Swarm if enabled, as that spawns multiple enemies, which we don't want bool swarmsWasEnabled = false; if (RunArtifactManager.instance.IsArtifactEnabled(RoR2Content.Artifacts.swarmsArtifactDef)) { RunArtifactManager.instance.SetArtifactEnabledServer(RoR2Content.Artifacts.swarmsArtifactDef, false); swarmsWasEnabled = true; } try { for (int i = 0; i < numSpawns; ++i) { // Add one more to make a slot for skipping Ally selection float angle = i * (360f / (numSpawns + 1)); GameObject barrel = SpawnBarrel(center, angle, radius).spawnedInstance; BarrelInteraction interaction = barrel.GetComponent <BarrelInteraction>(); interaction.goldReward = 0; interaction.expReward = 0; GameObject allyDummy = SpawnAllyDummy(characterAllies[i], center, angle, radius + 5f).spawnedInstance; ApplyDummyAI(allyDummy.GetComponent <BaseAI>(), master.GetBodyObject()); SetGodMode(allyDummy.GetComponent <CharacterMaster>(), true); ApplyPurchaseLogic(barrel, allyDummy); } // Add barrel to skip ally interaction float noAllyAngle = numSpawns * (360f / (numSpawns + 1)); GameObject noAllybarrel = SpawnBarrel(center, noAllyAngle, radius).spawnedInstance; BarrelInteraction noAllyInteraction = noAllybarrel.GetComponent <BarrelInteraction>(); noAllyInteraction.goldReward = 0; noAllyInteraction.expReward = 0; GameObject portal = SpawnPortal(center, noAllyAngle, radius + 5f).spawnedInstance; GenericInteraction portalInteraction = portal.GetComponent <GenericInteraction>(); portalInteraction.SetInteractabilityDisabled(); portalInteraction.onActivation.RemoveAllListeners(); //portalInteraction.onActivation.AddListener((interactor) => //{ // portalInteraction.SetInteractabilityDisabled(); // Chat.SendBroadcastChat(new Chat.SimpleChatMessage() // { // baseToken = $"<color=#{ColorUtility.ToHtmlStringRGB(Color.green)}>Protect the VIP:</color> " + // $"<color=#{ColorUtility.ToHtmlStringRGB(Color.gray)}>Starting run with no ally.</color>" // }); // GoToNextLevel(); //}); ApplyPurchaseLogic(noAllybarrel, null); } finally { if (swarmsWasEnabled) { RunArtifactManager.instance.SetArtifactEnabledServer(RoR2Content.Artifacts.swarmsArtifactDef, true); } } }
protected virtual void Start() { interaction = FindObjectOfType <Interaction>(); genericInteraction = GetComponent <GenericInteraction>(); }