public LProcess(LGame game) : base() { this._game = game; LSetting setting = _game.setting; setting.UpdateScale(); LSystem.viewSize.SetSize(setting.width, setting.height); this._bundle = new ObjectBundle(); this._currentInput = new SysInputFactory(); this._screens = new TArray <Screen>(); this._screenMap = new ListMap <string, Screen>(); this.Clear(); InputMake input = game.Input(); if (input != null) { //这部分与Java版没必要1:1实现,因为XNA有TouchPanel.GetCapabilities().IsConnected方法判定是否支持触屏 if (!game.setting.emulateTouch && !_game.Input().HasTouch()) { input.mouseEvents.Connect(new ButtonPort(this)); } else { input.touchEvents.Connect(new TouchPort(this)); } input.keyboardEvents.Connect(new KeyPort(this)); } game.status.Connect(new StatusPort(this)); }
void CreateBundlePanel(ObjectBundle bundle, Action <GameObject> buttonCallback) { var bundlePanel = Instantiate(bundlePanelPrefab); bundlePanel.transform.SetParent(bundleLayout); bundlePanel.transform.Find("Text").GetComponent <Text>().text = bundle.bundleName; var layout = bundlePanel.transform.Find("ObjectLayout"); foreach (var bundleObject in bundle.objects) { var description = bundleObject.GetComponent <ObjectDescription>(); var objectButton = Instantiate(objectButtonPrefab); objectButton.transform.SetParent(layout); objectButton.transform.Find("Image").GetComponent <Image>().sprite = description.objectImage; GameObject cur = bundleObject; // local variable for callback objectButton.GetComponent <Button>().onClick.AddListener(() => buttonCallback(cur)); } }