コード例 #1
0
        /// <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;
        }
コード例 #2
0
 public TransmuteOrder(ActorController actor, NeolithicObject target, ResourceKind fromResourceKind, ResourceKind toResourceKind)
 {
     this.fromResourceKind = fromResourceKind;
     this.toResourceKind   = toResourceKind;
     this.target           = target;
     GoToState(cGetSourceMaterial, actor);
 }
コード例 #3
0
        public override void OnInspectorGUI()
        {
            DrawDefaultInspector();
            NeolithicObject nobject = (NeolithicObject)target;

            if (GUILayout.Button("SnapToGround"))
            {
                nobject.SnapToGround(true);
            }
        }
コード例 #4
0
 public ConstructOrder(ActorController actor, NeolithicObject target)
 {
     manager = target.GetComponent <ConstructionManager>();
     GoToState(cGetConstructionJob, actor);
 }
コード例 #5
0
 public HarvestFromReservoirOrder(ActorController actor, NeolithicObject target)
 {
     targetObj = target;
     reservoir = target.GetComponent <Reservoir>();
     GoToState(cSeekTarget, actor);
 }
コード例 #6
0
 public UpgradeReservoirOrder(ActorController actor, NeolithicObject target, GameObject prefab) : base(actor)
 {
     targetObj = target;
     myPrefab  = prefab;
     GoToState("seekTarget", actor);
 }
コード例 #7
0
 public TearDownOrder(ActorController a, NeolithicObject target) : base()
 {
     a.GetComponent <NeolithicObject>().statusString = "Tearing down " + target.name;
     this.target = target;
 }
コード例 #8
0
 public FishOrder(ActorController actor, NeolithicObject target)
 {
     this.target = target;
     GoToState(cSeekTarget, actor);
 }
コード例 #9
0
 public DoBuildingUpgrade(ActorController a, NeolithicObject target, GameObject prefab) : base()
 {
     myTargetObj = target;
     myPrefab    = prefab;
 }
コード例 #10
0
 public CatchFishOrder(ActorController a, NeolithicObject fishingHole) : base()
 {
 }
コード例 #11
0
ファイル: FishOrder.cs プロジェクト: wangfei1988/CivilisUnity
 public FishOrder(ActorController actor, NeolithicObject target) : base(actor)
 {
     this.target = target;
     GoToState("seekTarget", actor);
 }
コード例 #12
0
 public MeditateOrder(ActorController a, NeolithicObject target) : base()
 {
 }
コード例 #13
0
 /// <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();
 }
コード例 #14
0
 /// <summary>
 /// Shows a selection menu for the given selected NeolithicObject
 /// </summary>
 /// <param name="selected"></param>
 public void ShowSelectionMenu(NeolithicObject selected)
 {
     selectionMenu.ShowPrimative(selected);
 }