/// <summary> /// Creates a context menu with the given opions and target object /// </summary> /// <param name="options"></param> /// <param name="target"></param> public void ShowContextMenu(CommandType[] options, NeolithicObject target) { if (!options.Any()) { contextMenu.SetActive(false); return; } contextMenu.SetActive(true); foreach (Transform child in contextMenu.transform) { Destroy(child.gameObject); } var prefab = Resources.Load("ContextTextButton") as GameObject; foreach (CommandType option in options) { var contextButton = GameController.Factory.Instantiate(prefab); var button = contextButton.GetComponent <Button>(); var command = option; button.onClick.AddListener(() => ExecuteContextAction(command, target)); contextButton.GetComponent <Text>().text = option.ToString(); contextButton.transform.SetParent(contextMenu.transform); } contextMenu.transform.position = Input.mousePosition; }
public TransmuteOrder(ActorController actor, NeolithicObject target, ResourceKind fromResourceKind, ResourceKind toResourceKind) { this.fromResourceKind = fromResourceKind; this.toResourceKind = toResourceKind; this.target = target; GoToState(cGetSourceMaterial, actor); }
public override void OnInspectorGUI() { DrawDefaultInspector(); NeolithicObject nobject = (NeolithicObject)target; if (GUILayout.Button("SnapToGround")) { nobject.SnapToGround(true); } }
public ConstructOrder(ActorController actor, NeolithicObject target) { manager = target.GetComponent <ConstructionManager>(); GoToState(cGetConstructionJob, actor); }
public HarvestFromReservoirOrder(ActorController actor, NeolithicObject target) { targetObj = target; reservoir = target.GetComponent <Reservoir>(); GoToState(cSeekTarget, actor); }
public UpgradeReservoirOrder(ActorController actor, NeolithicObject target, GameObject prefab) : base(actor) { targetObj = target; myPrefab = prefab; GoToState("seekTarget", actor); }
public TearDownOrder(ActorController a, NeolithicObject target) : base() { a.GetComponent <NeolithicObject>().statusString = "Tearing down " + target.name; this.target = target; }
public FishOrder(ActorController actor, NeolithicObject target) { this.target = target; GoToState(cSeekTarget, actor); }
public DoBuildingUpgrade(ActorController a, NeolithicObject target, GameObject prefab) : base() { myTargetObj = target; myPrefab = prefab; }
public CatchFishOrder(ActorController a, NeolithicObject fishingHole) : base() { }
public FishOrder(ActorController actor, NeolithicObject target) : base(actor) { this.target = target; GoToState("seekTarget", actor); }
public MeditateOrder(ActorController a, NeolithicObject target) : base() { }
/// <summary> /// Forwards a command to the game controller to issue the given order to the current /// selected units against the target, and then hides the context menu /// </summary> public void ExecuteContextAction(CommandType action, NeolithicObject target) { GameController.IssueOrder(action, target); HideContextMenu(); }
/// <summary> /// Shows a selection menu for the given selected NeolithicObject /// </summary> /// <param name="selected"></param> public void ShowSelectionMenu(NeolithicObject selected) { selectionMenu.ShowPrimative(selected); }