本文整理匯總了C#中AC.Recalculate方法的典型用法代碼示例。如果您正苦於以下問題:C# AC.Recalculate方法的具體用法?C# AC.Recalculate怎麽用?C# AC.Recalculate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類AC
的用法示例。
在下文中一共展示了AC.Recalculate方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: CheckScreenSize
private void CheckScreenSize(AC.Menu menu)
{
if (screenSize.x != Screen.width || screenSize.y != Screen.height)
{
screenSize = new Vector2 (Screen.width, Screen.height);
menu.Recalculate ();
}
}
示例2: OnMenuEnable
public static void OnMenuEnable(AC.Menu _menu)
{
// This function is called whenever a menu is enabled.
if (_menu.title == "Pause")
{
MenuElement saveButton = _menu.GetElementWithName ("SaveButton");
if (saveButton)
{
saveButton.isVisible = !PlayerMenus.IsSavingLocked ();
}
_menu.Recalculate ();
}
}
示例3: ProcessClick
public override void ProcessClick(AC.Menu _menu, int _slot, MouseState _mouseState)
{
if (KickStarter.stateHandler.gameState == GameState.Cutscene)
{
return;
}
base.ProcessClick (_menu, _slot, _mouseState);
if (craftingType == CraftingElementType.Ingredients)
{
HandleDefaultClick (_mouseState, _slot);
}
else if (craftingType == CraftingElementType.Output)
{
ClickOutput (_menu, _mouseState);
}
_menu.Recalculate ();
}
示例4: AddElement
private void AddElement(string className, AC.Menu _menu)
{
Undo.RecordObject (_menu, "Add element");
List<int> idArray = new List<int>();
foreach (MenuElement _element in _menu.elements)
{
if (_element != null)
{
idArray.Add (_element.ID);
}
}
idArray.Sort ();
className = "Menu" + className;
MenuElement newElement = (MenuElement) CreateInstance (className);
newElement.Declare ();
newElement.title = className.Substring (4);
// Update id based on array
foreach (int _id in idArray.ToArray())
{
if (newElement.ID == _id)
{
newElement.ID ++;
}
}
_menu.elements.Add (newElement);
if (!Application.isPlaying)
{
_menu.Recalculate ();
}
DeactivateAllElements (_menu);
newElement.isEditing = true;
selectedMenuElement = newElement;
newElement.hideFlags = HideFlags.HideInHierarchy;
AssetDatabase.AddObjectToAsset (newElement, this);
AssetDatabase.ImportAsset (AssetDatabase.GetAssetPath (newElement));
AssetDatabase.SaveAssets ();
CleanUpAsset ();
}
示例5: UpdateMenu
//.........這裏部分代碼省略.........
{
menu.TurnOff (true);
}
}
}
catch
{
if (KickStarter.settingsManager.inputMethod != InputMethod.TouchScreen)
{
Debug.LogWarning ("No '" + menu.toggleKey + "' button exists - please define one in the Input Manager.");
}
}
}
else if (menu.appearType == AppearType.OnHotspot)
{
if (KickStarter.settingsManager.interactionMethod == AC_InteractionMethod.ContextSensitive && !menu.isLocked && KickStarter.runtimeInventory.selectedItem == null)
{
Hotspot hotspot = KickStarter.playerInteraction.GetActiveHotspot ();
if (hotspot != null)
{
menu.HideInteractions ();
if (hotspot.HasContextUse ())
{
menu.MatchUseInteraction (hotspot.GetFirstUseButton ());
}
if (hotspot.HasContextLook ())
{
menu.MatchLookInteraction (hotspot.lookButton);
}
menu.Recalculate ();
}
}
if (hotspotLabel != "" && !menu.isLocked && KickStarter.stateHandler.gameState != GameState.Cutscene)
//(KickStarter.stateHandler.gameState == GameState.Normal || KickStarter.stateHandler.gameState == GameState.DialogOptions))
{
if (!menu.IsOn ())
{
menu.TurnOn (true);
if (menu.IsUnityUI ())
{
// Update position before next frame (Unity UI bug)
UpdateMenuPosition (menu, invertedMouse);
}
}
}
//else if (KickStarter.stateHandler.gameState == GameState.Paused)
else if (KickStarter.stateHandler.gameState == GameState.Cutscene)
{
menu.ForceOff ();
}
else
{
menu.TurnOff (true);
}
}
else if (menu.appearType == AppearType.OnInteraction)
{
if (KickStarter.settingsManager.CanClickOffInteractionMenu ())
{
if (menu.IsEnabled () && (KickStarter.stateHandler.gameState == GameState.Normal || menu.pauseWhenEnabled))
示例6: UpdateMenuPosition
/**
* <summary>Updates a Menu's position.</summary>
* <param name = "menu">The Menu to reposition</param>
* <param name = "invertedMouse">The y-inverted mouse position</param>
*/
public void UpdateMenuPosition(AC.Menu menu, Vector2 invertedMouse)
{
if (menu.IsUnityUI ())
{
if (Application.isPlaying)
{
Vector2 screenPosition = Vector2.zero;
if (menu.uiPositionType == UIPositionType.Manual)
{
return;
}
else if (menu.uiPositionType == UIPositionType.FollowCursor)
{
screenPosition = new Vector2 (invertedMouse.x, Screen.height + 1f - invertedMouse.y);
menu.SetCentre (screenPosition);
}
else if (menu.uiPositionType == UIPositionType.OnHotspot)
{
if (!menu.IsFadingOut ())
{
if (mouseOverInventory)
{
screenPosition = new Vector2 (activeInventoryBoxCentre.x, Screen.height + 1f - activeInventoryBoxCentre.y);
menu.SetCentre (screenPosition);
}
else if (KickStarter.playerInteraction.GetActiveHotspot ())
{
if (menu.canvas.renderMode == RenderMode.WorldSpace)
{
menu.SetCentre (KickStarter.playerInteraction.GetActiveHotspot ().transform.position);
}
else
{
screenPosition = KickStarter.playerInteraction.GetHotspotScreenCentre ();
screenPosition = new Vector2 (screenPosition.x * Screen.width, (1f - screenPosition.y) * Screen.height);
menu.SetCentre (screenPosition);
}
}
}
}
else if (menu.uiPositionType == UIPositionType.AboveSpeakingCharacter)
{
Char speaker = null;
if (dupMenus.Contains (menu))
{
if (menu.speech != null)
{
speaker = menu.speech.GetSpeakingCharacter ();
}
}
else
{
speaker = KickStarter.dialog.GetSpeakingCharacter ();
}
if (speaker != null)
{
if (menu.canvas.renderMode == RenderMode.WorldSpace)
{
menu.SetCentre (speaker.transform.position);
}
else
{
screenPosition = speaker.GetScreenCentre ();
screenPosition = new Vector2 (screenPosition.x * Screen.width, (1f - screenPosition.y) * Screen.height);
menu.SetCentre (screenPosition);
}
}
}
else if (menu.uiPositionType == UIPositionType.AbovePlayer)
{
if (KickStarter.player)
{
if (menu.canvas.renderMode == RenderMode.WorldSpace)
{
menu.SetCentre (KickStarter.player.transform.position);
}
else
{
screenPosition = KickStarter.player.GetScreenCentre ();
screenPosition = new Vector2 (screenPosition.x * Screen.width, (1f - screenPosition.y) * Screen.height);
menu.SetCentre (screenPosition);
}
}
}
}
return;
}
if (menu.sizeType == AC_SizeType.Automatic && menu.autoSizeEveryFrame)
{
menu.Recalculate ();
//.........這裏部分代碼省略.........
示例7: ProcessInventoryBoxClick
/**
* <summary>Processes the clicking of an inventory item within a MenuInventoryBox element</summary>
* <param name = "_menu">The Menu that contains the MenuInventoryBox element</param>
* <param name = "inventoryBox">The MenuInventoryBox element that was clicked on</param>
* <param name = "_slot">The index number of the MenuInventoryBox slot that was clicked on</param>
* <param name = "_mouseState">The state of the mouse when the click occured (Normal, SingleClick, RightClick, DoubleClick, HeldDown, LetGo)</param>
*/
public void ProcessInventoryBoxClick(AC.Menu _menu, MenuInventoryBox inventoryBox, int _slot, MouseState _mouseState)
{
if (inventoryBox.inventoryBoxType == AC_InventoryBoxType.Default || inventoryBox.inventoryBoxType == AC_InventoryBoxType.DisplayLastSelected)
{
if (KickStarter.settingsManager.inventoryInteractions == InventoryInteractions.Multiple && KickStarter.playerMenus.IsInteractionMenuOn ())
{
KickStarter.playerMenus.SetInteractionMenus (false);
ClickInvItemToInteract ();
}
else if (KickStarter.settingsManager.inventoryInteractions == InventoryInteractions.Multiple && KickStarter.settingsManager.SelectInteractionMethod () == AC.SelectInteractions.CyclingCursorAndClickingHotspot)
{
if (KickStarter.settingsManager.autoCycleWhenInteract && _mouseState == MouseState.SingleClick && (selectedItem == null || KickStarter.settingsManager.cycleInventoryCursors))
{
int originalIndex = KickStarter.playerInteraction.GetInteractionIndex ();
KickStarter.playerInteraction.SetNextInteraction ();
KickStarter.playerInteraction.SetInteractionIndex (originalIndex);
}
if (!KickStarter.settingsManager.cycleInventoryCursors && selectedItem != null)
{
inventoryBox.HandleDefaultClick (_mouseState, _slot, KickStarter.settingsManager.interactionMethod);
}
else if (_mouseState != MouseState.RightClick)
{
KickStarter.playerMenus.SetInteractionMenus (false);
ClickInvItemToInteract ();
}
if (KickStarter.settingsManager.autoCycleWhenInteract && _mouseState == MouseState.SingleClick)
{
KickStarter.playerInteraction.RestoreInventoryInteraction ();
}
}
else if (KickStarter.settingsManager.interactionMethod != AC_InteractionMethod.ContextSensitive && KickStarter.settingsManager.inventoryInteractions == InventoryInteractions.Single)
{
inventoryBox.HandleDefaultClick (_mouseState, _slot, AC_InteractionMethod.ContextSensitive);
}
else
{
inventoryBox.HandleDefaultClick (_mouseState, _slot, KickStarter.settingsManager.interactionMethod);
}
_menu.Recalculate ();
}
else if (inventoryBox.inventoryBoxType == AC_InventoryBoxType.Container)
{
inventoryBox.ClickContainer (_mouseState, _slot, KickStarter.playerInput.activeContainer);
_menu.Recalculate ();
}
else if (inventoryBox.inventoryBoxType == AC_InventoryBoxType.HotspotBased)
{
if (KickStarter.settingsManager.interactionMethod == AC_InteractionMethod.ChooseHotspotThenInteraction)
{
if (_menu.GetTargetInvItem () != null)
{
//Combine (hoverItem, inventoryBox.items [_slot]);
Combine (_menu.GetTargetInvItem (), inventoryBox.items [_slot + inventoryBox.GetOffset ()]);
}
else if (_menu.GetTargetHotspot ())
{
InvItem _item = inventoryBox.items [_slot + inventoryBox.GetOffset ()];
if (_item != null)
{
//SelectItem (_item, SelectItemMode.Use);
_menu.TurnOff (false);
KickStarter.playerInteraction.ClickButton (InteractionType.Inventory, -2, _item.id, _menu.GetTargetHotspot ());
KickStarter.playerCursor.ResetSelectedCursor ();
}
}
else
{
ACDebug.LogWarning ("Cannot handle inventory click since there is no active Hotspot.");
}
}
else
{
ACDebug.LogWarning ("This type of InventoryBox only works with the Choose Hotspot Then Interaction method of interaction.");
}
}
}
示例8: ProcessClick
/**
* <summary>Performs what should happen when the element is clicked on.</summary>
* <param name = "_menu">The element's parent Menu</param>
* <param name = "_slot">Ignored by this subclass</param>
* <param name = "_mouseState">The state of the mouse button</param>
*/
public override void ProcessClick(AC.Menu _menu, int _slot, MouseState _mouseState)
{
if (KickStarter.stateHandler.gameState == GameState.Cutscene)
{
return;
}
base.ProcessClick (_menu, _slot, _mouseState);
ShowClick ();
if (buttonClickType == AC_ButtonClickType.TurnOffMenu)
{
_menu.TurnOff (doFade);
}
else if (buttonClickType == AC_ButtonClickType.Crossfade)
{
AC.Menu menuToSwitchTo = PlayerMenus.GetMenuWithName (switchMenuTitle);
if (menuToSwitchTo != null)
{
KickStarter.playerMenus.CrossFade (menuToSwitchTo);
}
else
{
ACDebug.LogWarning ("Cannot find any menu of name '" + switchMenuTitle + "'");
}
}
else if (buttonClickType == AC_ButtonClickType.OffsetElementSlot)
{
if (elementToShift != null)
{
elementToShift.Shift (shiftInventory, shiftAmount);
elementToShift.RecalculateSize (_menu.menuSource);
_menu.Recalculate ();
}
else
{
ACDebug.LogWarning ("Cannot find '" + inventoryBoxTitle + "' inside '" + _menu.title + "'");
}
}
else if (buttonClickType == AC_ButtonClickType.OffsetJournal)
{
MenuJournal journalToShift = (MenuJournal) PlayerMenus.GetElementWithName (_menu.title, inventoryBoxTitle);
if (journalToShift != null)
{
journalToShift.Shift (shiftInventory, loopJournal, shiftAmount);
journalToShift.RecalculateSize (_menu.menuSource);
_menu.Recalculate ();
}
else
{
ACDebug.LogWarning ("Cannot find '" + inventoryBoxTitle + "' inside '" + _menu.title + "'");
}
}
else if (buttonClickType == AC_ButtonClickType.RunActionList)
{
if (actionList)
{
AdvGame.RunActionListAsset (actionList, parameterID, parameterValue);
}
}
else if (buttonClickType == AC_ButtonClickType.CustomScript)
{
MenuSystem.OnElementClick (_menu, this, _slot, (int) _mouseState);
}
else if (buttonClickType == AC_ButtonClickType.SimulateInput)
{
KickStarter.playerInput.SimulateInput (simulateInput, inputAxis, simulateValue);
}
}