// 0 for team 1; 1 for team 2 because indexing // Start is called before the first frame update void Start() { myCol = this.GetComponent <Collider2D>(); resPool = GetComponent <ResourceBag>(); baseStats = GetComponent <PlayerStats>(); TeleportTile[] tels = GetComponentsInChildren <TeleportTile>(); mnm = GameObject.Find("NetworkManager").GetComponent <MonumentalNetworkManager>(); gameSettings = GameObject.FindObjectOfType <GameSettings>(); uiControl = GameObject.FindObjectOfType <UI_Control>(); lastPurchase = Time.time; for (int i = 0; i < tels.Length; i++) { tels[i].teamIndex = teamIndex; } if (isServer) { upgrade1level = 1; upgrade2level = 1; upgrade3level = 1; upgrade4level = 1; upgrade5level = 1; upgrade6level = 1; } monuments = GameObject.FindObjectOfType <Monuments>(); }
// Start is called before the first frame update void Start() { hitDetect = GetComponentInChildren <HitDetection>(); attackAnimator = GetComponentInChildren <Animator>(); shootingProjectile = GetComponent <ShootingProjectiles>(); stats = GetComponent <PlayerStats>(); body = GetComponent <Rigidbody2D>(); currentHealth = stats.getHealth(); resources = GetComponent <ResourceBag>(); resources.initEmpty(); abovePlayerUI = (Instantiate(Resources.Load("UI/Healthbar")) as GameObject); healthbar = abovePlayerUI.GetComponentInChildren <Slider>(); nameUI = abovePlayerUI.GetComponentInChildren <TMPro.TextMeshProUGUI>(); spawn = new Vector2(transform.position.x, transform.position.y); timeOfLastClick = Time.time; if (isLocalPlayer) { hitDetect.isTheLocalPlayer = true; uiControl = GameObject.FindObjectOfType <UI_Control>(); uiControl.player = this; UI_Camera uiCamera = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <UI_Camera>(); mnmenu = GameObject.FindObjectOfType <MonumentalNetworkMenu>(); uiCamera.followTarget = this.gameObject; currentHealth = stats.getHealth(); spriteRender = this.GetComponent <SpriteRenderer>(); spriteRender.sprite = classSprites[stats.Class]; } }
public override void OnStart(StartState state) { if (!AreConfigsRead) { ReadCustomConfigs(); PopulateFuelNames(); AreConfigsRead = true; } if (HighLogic.LoadedScene == GameScenes.EDITOR) { UI_Control c = this.Fields["fuelSelectorIndex"].uiControlEditor; c.onFieldChanged = updateFuelSetup; UI_ChooseOption o = (UI_ChooseOption)c; o.options = FuelNames; this.updateFuelSetup(this.fuelSelectorIndex); } this.updateUIOutput(this.fuelPep, this.efficiency); if (HighLogic.LoadedScene == GameScenes.FLIGHT) { this.updateFuelSetup(this.fuelSelectorIndex); this.part.force_activate(); } }
// ReSharper disable ParameterHidesMember public override void Setup(UIPartActionWindow window, Part part, UI_Scene scene, UI_Control control, PartResource resource) { double amount = resource.amount; base.Setup(window, part, scene, control, resource); this.resource.amount = amount; slider.SetValueChangedDelegate(OnSliderChanged); }
public static void InitializeTweakable <T>( UI_Control floatRange, ref float localField, ref float remoteField, bool clobberEverywhere = false ) { InitializeTweakable <T>(floatRange, ref localField, ref remoteField, remoteField, clobberEverywhere); }
// Initialize the gimbal range tweakable and value. #if false public static void InitializeTweakable <T>( UI_Control floatRange, ref float localField, ref float remoteField, float centerValue, float lowerMult, float upperMult, bool clobberEverywhere = false )
private bool T_traversing;//方向机是否在工作 #endregion #region 静态变量 #endregion // Use this for initialization void Start() { //初始化音源部分 { engineAudio = gameObject.AddComponent <AudioSource>(); engineAudio.playOnAwake = false; engineAudio.clip = s_Engine; engineAudio.spatialBlend = 0.3f; engineAudio.loop = true; fireAudio = gameObject.AddComponent <AudioSource>(); fireAudio.playOnAwake = false; fireAudio.spatialBlend = 1; traversingWork = gameObject.AddComponent <AudioSource>(); traversingWork.playOnAwake = false; traversingWork.clip = s_Traversing; traversingWork.spatialBlend = 1; traversingWork.loop = true; othersAudio = gameObject.AddComponent <AudioSource>(); othersAudio.playOnAwake = false; othersAudio.spatialBlend = 1; } if (ctrltype == CtrlType.player) //是玩家控制的场合 { Camera_Main.Target_Nomal = camera_Target.gameObject; //设置为摄像机目标 Camera_Main.Target_Snip = SnipSights.gameObject; gameObject.AddComponent <AudioListener>(); //添加声音接收器 } mmRigidbody = gameObject.GetComponent <Rigidbody>(); //初始化火力部分 reloadingProgress = fullReloadingtime; ammunitionNext = ammunition[ammunitionNum]; ammunitionInBore = ammunitionNext; //n_Clip = Clip; inbore = false; //fullClip = false; //初始化机动部分 L_tracks = gameObject.transform.Find("L_Track"); R_tracks = gameObject.transform.Find("R_Track"); L_wheels = gameObject.transform.Find("L_Wheels"); R_wheels = gameObject.transform.Find("R_Wheels"); LT = L_tracks.gameObject.GetComponent <MeshRenderer>(); RT = R_tracks.gameObject.GetComponent <MeshRenderer>(); //初始化AI部分 ai = gameObject.AddComponent <AI>(); ai.tank = this; //初始化UI部分 ui_Contorl = ui_Manager.GetComponent <UI_Control>(); }
public override void OnStart(StartState state) { Log.dbg("OnStart {0}:{1:X} {2}", this.name, this.part.GetInstanceID(), state); base.OnStart(state); BaseField field = this.Fields["increaseSlotsNumber"]; UI_Control uiControl = (field.uiControlEditor as UI_Toggle); uiControl.onFieldChanged += this.OnIncreaseSlotsNumberChange; }
// Called when item is pressed public void ChooseScenario() { // Find UI manager to select this scenario to UI_Control ui_control = GameObject.FindObjectOfType <UI_Control>(); if (ui_control != null) { ui_control.ChooseScenario(thisScenario); } }
static void setup_chooser_control(string[] names, string[] values, UI_Control control) { var current_editor = control as UI_ChooseOption; if (current_editor == null) { return; } current_editor.display = names; current_editor.options = values; }
public override void OnStart(StartState state) { try { if (PPart is null) { Debug.LogError($"{ModTag} {part}.{this} Procedural Part not found"); return; } // isMirrored flag is required for correct bell deflection - real deflection angles is multiplied by // -1 on mirrored part. // Because of this, we need to check if we've been created off of the part that already was "mirrored" // and set out flag accordingly. isMirrored = part.symMethod == SymmetryMethod.Mirror && part.symmetryCounterparts.Count > 0 && !part.symmetryCounterparts[0].GetComponent <ProceduralSRB>().isMirrored; bottomAttachNode = part.FindAttachNode(bottomAttachNodeName); InitializeBells(); UpdateMaxThrust(); if (HighLogic.LoadedSceneIsEditor) { UI_Control uiBell = Fields[nameof(selectedBellName)].uiControlEditor; uiBell.onFieldChanged += HandleBellTypeChange; uiBell.onSymmetryFieldChanged += HandleBellTypeChange; UI_Control uiDeflection = Fields[nameof(thrustDeflection)].uiControlEditor; uiDeflection.onFieldChanged += HandleBellDeflectionChange; // onSymmetryFieldChanged is buggy here, will call handler for symmetry counterparts ourselves if (UsingME) { UI_Control uiBurnTimeME = Fields[nameof(burnTimeME)].uiControlEditor; uiBurnTimeME.onFieldChanged += HandleThrustChange; uiBurnTimeME.onSymmetryFieldChanged += HandleThrustChange; } else { UI_Control uiThrust = Fields[nameof(thrust)].uiControlEditor; uiThrust.onFieldChanged += HandleThrustChange; uiThrust.onSymmetryFieldChanged += HandleThrustChange; } } } catch (Exception ex) { Debug.Log($"{ModTag}: OnStart exception: {ex}"); throw; } }
private void SingletonMaker() { if (main == null) { DontDestroyOnLoad(gameObject); main = this; Debug.Log("Control Panel created"); } else if (main != this) { Destroy(gameObject); } }
// Start is called before the first frame update void Start() { uI_Control = UI_Control.Instance; GameObject ControlKeyObj = new GameObject(); controlKeyAndDelay = ControlKeyObj.AddComponent <ControlKeyAndDelay>(); Input.gyro.enabled = true; Input.gyro.updateInterval = 0.0167f; JumpKeyAndDelay = new ControlKeyAndDelay.KeyAndDelay("Jump", TimeKeyJumpDelay); HitKeyAndDelay = new ControlKeyAndDelay.KeyAndDelay("Hit", TimeKeyHitDelay); ShootKeyAndDelay = new ControlKeyAndDelay.KeyAndDelay("Shoot", TimeKeyShootDelay); soundControl = SoundControl.Instance; playerControl = PlayerControl.Instance; }
public void Init() { ui_control = GameObject.Find ("UI Manager").GetComponent<UI_Control>(); slotItem = new UI_SlotItem[slotSize]; for (int loop = 0; loop < slotSize; loop++) { slotItem[loop] = transform.GetChild(loop + 1).gameObject.GetComponent<UI_SlotItem>(); slotItem[loop].UI_SlotItem_Start(GetComponent<UI_Slot>(), loop); } selected = transform.GetChild (0).gameObject; selected.SetActive (false); selected_index = -1; player = ui_control.GetPlayer (); refitDis = Mathf.Pow(ui_control.BottomSlotLength * 0.12f ,2); }
public void Init_Skill() { gameManager = GameObject.Find ("GameManager").GetComponent<GameManager> (); ui_control = GameObject.Find ("UI Manager").GetComponent<UI_Control> (); selected = transform.Find ("Selected_Skill").gameObject; skillName = GameObject.Find ("SkillName").GetComponent<Text> (); skillEffect = GameObject.Find ("SkillEffect").GetComponent<Text> (); skillExplain = GameObject.Find ("SkillExplain").GetComponent<Text> (); Off (); btn = new Transform[5]; for (int loop = 0; loop < 5; loop++) { btn[loop] = transform.GetChild(loop + 1); } }
/// <summary> /// Ensures that max setting of the FloatRange UI control is not less than the provided value. /// </summary> void SetupFloatUiControlMax(BaseField field, UI_Control control, float refValue) { if (control != null) { var uiFloat = control as UI_FloatRange; if (uiFloat == null) { HostedDebugLog.Error( this, "Field is not of a FloatRange type: {0}", field.MemberInfo.Name); return; } if (uiFloat.maxValue < refValue) { HostedDebugLog.Fine( this, "Adjust field max value: field={0}, oldMax={1}, newMax={2}", field.MemberInfo.Name, uiFloat.maxValue, refValue); uiFloat.maxValue = refValue; } } }
public BaseField GetField() { var fields = new BaseFieldList(this); BaseField bf = fields[0]; bf.guiName = name; UI_Control control = null; if (HighLogic.LoadedSceneIsEditor) { control = bf.uiControlEditor; } else if (HighLogic.LoadedSceneIsFlight) { control = bf.uiControlFlight; } if (control != null) { control.onFieldChanged += ModifyValue; } return(bf); }
public override void OnStart(StartState state) { base.OnStart(state); _data = new AswData { Type = type }; switch (_data.Type) { case "DepthCharge": _bomb = new BombSystem(); _bomb.ChargeDataWrite(errorRange, maxDepth, maxDepth); _bomb.Ran(); _buoyancy = new Buoyancy(); _buoyancy.BuoyancyDataWrite(volumebuoyancy, volum, buoyancyForce); _rota = new RotationSystem(); _rota.RotationData(airMaxTorque, waterMaxTorque, airCocf, waterCocf); _missileLauncher = GetComponent <MissileLauncher>(); if (_missileLauncher == null) { Debug.LogError("Failed when find the MissileLauncher!"); } _depthField = Fields["autoDestroyDepth"].uiControlFlight; Fields["cruiseDepth"].guiActive = false; Fields["cruiseDepth"].guiActiveEditor = false; Fields["autoDestroyDepth"].guiActive = true; Fields["autoDestroyDepth"].guiActiveEditor = true; Fields["autoDestroyDepth"].guiName = Localizer.Format("#autoLOC_NAS_Editor_detonateDepth"); ((UI_FloatRange)Fields["autoDestroyDepth"].uiControlEditor).maxValue = maxDepth; ((UI_FloatRange)Fields["autoDestroyDepth"].uiControlFlight).maxValue = maxDepth; break; case "Torpedo": _pida = new PidSystem(); _pida.PidDataWrite(maxRotate.z, pidAngleInfo.x, pidAngleInfo.y, pidAngleInfo.z); _pidt = new PidSystem(); _pidt.PidDataWrite(maxTorque.x, pidTorqueInfo.x, pidTorqueInfo.y, pidTorqueInfo.z); _buoyancy = new Buoyancy(); _buoyancy.BuoyancyDataWrite(volumebuoyancy, volum, buoyancyForce); _rota = new RotationSystem(); _rota.RotationData(airMaxTorque, waterMaxTorque, airCocf, waterCocf); _missileLauncher = GetComponent <MissileLauncher>(); if (_missileLauncher == null) { Debug.LogError("Failed when find the MissileLauncher!"); } Fields["autoDestroyDepth"].guiActive = false; Fields["autoDestroyDepth"].guiActiveEditor = false; Fields["cruiseDepth"].guiActive = true; Fields["cruiseDepth"].guiActiveEditor = true; Fields["cruiseDepth"].guiName = Localizer.Format("#autoLOC_NAS_Editor_cruiseDepth"); ((UI_FloatRange)Fields["cruiseDepth"].uiControlEditor).maxValue = maxDepth - 2; ((UI_FloatRange)Fields["cruiseDepth"].uiControlFlight).maxValue = maxDepth - 2; break; default: Debug.LogWarning("[NAS-ASW]Neither depth charge nor torpedo!"); break; } autoDestroyDepth = ModUiManager.setAllDepthCharges; cruiseDepth = ModUiManager.setAllTorpedos; }
private void Awake() { soundControl = SoundControl.Instance; uI_Control = UI_Control.Instance; }
public static MemberUpdater Create(object obj, string name) { if (obj == null || name == null) { return(null); } Type objectType = obj.GetType(); FieldInfo field = objectType.GetField(name, LookupFlags); PropertyInfo property = objectType.GetProperty(name, LookupFlags); UI_FloatRange floatRange = null; BaseFieldList fields; if (obj is PartModule) { fields = (obj as PartModule).Fields; try { BaseField fieldData = fields[name]; if ((object)fieldData != null) { UI_Control ctrl = fieldData.uiControlEditor; if (ctrl is UI_FloatRange) { floatRange = ctrl as UI_FloatRange; } } } catch (Exception) { string debuglog = "===============================================\r\n"; ConcatSafely("objectType", () => { return(objectType.ToString()); }, ref debuglog); ConcatSafely("name", () => { return(name); }, ref debuglog); ConcatSafely("fields.ReflectType", () => { return(fields.ReflectedType.ToString().ToString()); }, ref debuglog); ConcatSafely("fields.Count", () => { return(fields.Count.ToString()); }, ref debuglog); ConcatSafely("fields.Count", () => { string acc = ""; int numFields = fields.Count; for (int i = 0; i < numFields; i++) { ConcatSafely("field", () => { return(fields[i].ToString_rec(1)); }, ref acc); } return(acc); }, ref debuglog); Log.warn(debuglog); } } if (property != null && property.GetIndexParameters().Length > 0) { Log.warn("Property {0} on {1} requires indices, which TweakScale currently does not support.", name, objectType.Name); return(null); } if (field == null && property == null) { // handle special cases if ((obj is PartModule) && (name == "inputResources" || name == "outputResources")) { return(Create((obj as PartModule).resHandler, name)); } string partname = (obj is PartModule) ? (obj as PartModule).part.name : "<unk>"; Log.warn("No valid member found for {0} in {1} for {2}", name, objectType.Name, partname); return(null); } return(new MemberUpdater(obj, field, property, floatRange)); }
// ReSharper disable ParameterHidesMember public override void Setup(UIPartActionWindow window, Part part, PartModule partModule, UI_Scene scene, UI_Control control, BaseField field) { base.Setup(window, part, partModule, scene, control, field); incLargeDown.SetValueChangedDelegate(obj => buttons_ValueChanged(false)); incLargeUp.SetValueChangedDelegate(obj => buttons_ValueChanged(true)); slider.SetValueChangedDelegate(slider_OnValueChanged); // so update runs. value = GetFieldValue() + 0.1f; UpdateFieldInfo(); }
// ReSharper disable ParameterHidesMember public override void Setup(UIPartActionWindow window, Part part, UI_Scene scene, UI_Control control, PartResource resource) { double amount = resource.amount; base.Setup(window, part, scene, control, resource); this.resource.amount = amount; slider.SetValueChangedDelegate(OnSliderChanged); }
void Awake() { manager = GetComponent <NetworkManager>(); uiControl = GameObject.FindObjectOfType <UI_Control>(); }
public override void Setup(UIPartActionWindow window, Part part, PartModule partModule, UI_Scene scene, UI_Control control, BaseField field) { base.Setup(window, part, partModule, scene, control, field); ModuleB9PartSwitch switcherModule = (ModuleB9PartSwitch)partModule; SwitcherSubtypeDescriptionGenerator subtypeDescriptionGenerator = new SwitcherSubtypeDescriptionGenerator(switcherModule); subtypeButtons = new List <UIPartActionSubtypeButton>(switcherModule.subtypes.Count); int buttonIndex = 0; for (int i = 0; i < switcherModule.subtypes.Count; i++) { PartSubtype subtype = switcherModule.subtypes[i]; if (!subtype.IsUnlocked()) { continue; } GameObject buttonGameObject = Instantiate(prefabVariantButton, scrollMain.content); UIPartActionSubtypeButton subtypeButton = buttonGameObject.GetComponent <UIPartActionSubtypeButton>(); // prevent capturing in closures int subtypeIndex = i; int theButtonIndex = buttonIndex; subtypeButton.Setup( subtype.title, subtypeDescriptionGenerator.GetFullSubtypeDescription(subtype), subtype.PrimaryColor, subtype.SecondaryColor, () => SetSubtype(subtypeIndex, theButtonIndex) ); subtypeButtons.Add(subtypeButton); if (subtype == switcherModule.CurrentSubtype) { currentButtonIndex = buttonIndex; } buttonIndex++; } subtypeButtons[0].previousItem = subtypeButtons[subtypeButtons.Count - 1]; subtypeButtons[0].nextItem = subtypeButtons[1]; for (int i = 1; i < subtypeButtons.Count - 1; i++) { subtypeButtons[i].previousItem = subtypeButtons[i - 1]; subtypeButtons[i].nextItem = subtypeButtons[i + 1]; } subtypeButtons[subtypeButtons.Count - 1].previousItem = subtypeButtons[subtypeButtons.Count - 2]; subtypeButtons[subtypeButtons.Count - 1].nextItem = subtypeButtons[0]; switcherDescriptionText.text = switcherModule.switcherDescription; TooltipHelper.SetupSubtypeInfoTooltip(buttonPreviousTooltipController, "", ""); TooltipHelper.SetupSubtypeInfoTooltip(buttonNextTooltipController, "", ""); SetTooltips(currentButtonIndex); buttonPrevious.onClick.AddListener(PreviousSubtype); buttonNext.onClick.AddListener(NextSubtype); subtypeTitleText.text = switcherModule.CurrentSubtype.title; subtypeButtons[currentButtonIndex].Activate(); }
// Start is called before the first frame update void Start() { m_UI_Control = GameObject.Find("UI").GetComponent <UI_Control>(); }
// ReSharper disable ParameterHidesMember public override void Setup(UIPartActionWindow window, Part part, PartModule partModule, UI_Scene scene, UI_Control control, BaseField field) { base.Setup(window, part, partModule, scene, control, field); incDown.SetValueChangedDelegate(obj => IncrementValue(false)); incUp.SetValueChangedDelegate(obj => IncrementValue(true)); slider.SetValueChangedDelegate(OnValueChanged); }
// ReSharper disable ParameterHidesMember public override void Setup(UIPartActionWindow window, Part part, PartModule partModule, UI_Scene scene, UI_Control control, BaseField field) { base.Setup(window, part, partModule, scene, control, field); incLargeDown.SetValueChangedDelegate(obj => buttons_ValueChanged(false)); incLargeUp.SetValueChangedDelegate(obj => buttons_ValueChanged(true)); slider.SetValueChangedDelegate(slider_OnValueChanged); // so update runs. value = GetFieldValue() + 0.1f; UpdateFieldInfo(); }
// ReSharper disable ParameterHidesMember public override void Setup(UIPartActionWindow window, Part part, PartModule partModule, UI_Scene scene, UI_Control control, BaseField field) { base.Setup(window, part, partModule, scene, control, field); incDown.SetValueChangedDelegate(obj => IncrementValue(false)); incUp.SetValueChangedDelegate(obj => IncrementValue(true)); slider.SetValueChangedDelegate(OnValueChanged); }
public override void initChild(int charCode_) { ui_control = GameObject.Find ("UI Manager").GetComponent<UI_Control> (); ui_control.SetPlayer (GetComponent<Player> ()); charCode = charCode_; coolTime = new int[5]{0,0,0,0,0}; playerLevel = 1; currExp = 0; fullExp = Config.requiredExp [playerLevel - 1]; for(int i = 0 ; i < Config.inventoryRow * Config.inventoryCol;i++){ drink[i] = null; } for(int i = 0 ; i < Config.inventoryRow * Config.inventoryCol;i++){ equip[i] = null; } equip [4] = new Gold (); equip [4].init (-1, 0, 0); }
public static void InitializeTweakable <T>( UI_Control floatTweakable, ref float localField, ref float remoteField, float centerValue, float lowerMult, float upperMult, float stepMult, bool clobberEverywhere = false ) { if (floatTweakable == null) { Logging.PostErrorMessage("Got null Control during InitializeTweakable for type {0}; bailing out.", typeof(T).FullName); return; } Vector2 bounds; float minValue, maxValue, stepIncrement; bounds = LoadBounds <T>(); stepMult = LoadStep <T>(stepMult); // If our field is uninitialized... if (localField < 0) { // ...fetch it from the remote field localField = centerValue; } lowerMult = Mathf.Max(lowerMult, bounds.x, 0); upperMult = Mathf.Max(lowerMult, Mathf.Min(upperMult, bounds.y)); // Set the bounds and increment for our tweakable range. if (centerValue < 0) { maxValue = centerValue * lowerMult; minValue = centerValue * upperMult; } else { minValue = centerValue * lowerMult; maxValue = centerValue * upperMult; } stepIncrement = Mathf.Pow(10f, Mathf.RoundToInt(Mathf.Log10(Mathf.Abs(centerValue))) - 1); stepIncrement *= stepMult; if (floatTweakable is UI_FloatRange) { UI_FloatRange floatRange = floatTweakable as UI_FloatRange; floatRange.maxValue = maxValue; floatRange.minValue = minValue; floatRange.stepIncrement = stepIncrement; } else { Logging.PostErrorMessage( "InitializeTweakable<{0}>: Got floatTweakable of type {1}, expected {2}", typeof(T).FullName, floatTweakable.GetType().FullName, typeof(UI_FloatRange).FullName ); return; } localField = Mathf.Clamp(localField, minValue, maxValue); if (HighLogic.LoadedSceneIsFlight || clobberEverywhere) { // Clobber the remote field with ours. remoteField = localField; } }
void Start() { itemBeingDragged = GameObject.Find ("Panel_Slot").transform; ui_control = GameObject.Find ("UI Manager").GetComponent<UI_Control> (); startY = itemBeingDragged.position.y; maxY = startY - GameObject.Find ("ParamY_Slot").transform.position.y; corouLock = true; sideBtn = new GameObject[2]; sideBtn [0] = GameObject.Find ("Button_Investigate"); sideBtn [1] = GameObject.Find ("Button_Hold"); }