protected virtual void Awake() { try { var ini = new INIParser(); ini.Open(Application.dataPath + "/Config.txt"); this.InitialMoney = ini.ReadValue("Debug", "InitialMoney", this.InitialMoney); this.CenterBuilding.HPLimit = ini.ReadValue("Debug", "CenterHPLimit", this.CenterBuilding.HPLimit); this.CurrentRound = ini.ReadValue("Debug", "StartRound", this.CurrentRound); } catch (System.Exception) { } Initialize(); try { var info = new FileInfo(Application.dataPath + "/Generator.csv"); var text = File.ReadAllText(info.FullName, Encoding.UTF8); var data = FunctionExtension.CSVReader(text); this.CSVGeneratorsList = new List <EnemyGenerator>(); foreach (var item in data) { this.CSVGeneratorsList.Add(EnemyGenerator.CreateEnemyGenerator(this, item)); } } catch (System.Exception) { this.CSVGeneratorsList = null; } }
public bool TryGetExtension(Function functions, out FunctionExtension result) { result = null; TypeExtension typeExt; return(TryGetExtension(functions.DeclaringType, out typeExt) && typeExt.MethodExtensions.TryGetValue(functions.Prototype.MasterDefinition, out result)); }
private float GetTilingX() { if (Random.value >= 0.5f) { return(FunctionExtension.Remap(Random.value, 0f, 1f, 1f, this.LimitTiling.y)); } else { return(FunctionExtension.Remap(Random.value, 0f, 1f, this.LimitTiling.x, 1f)); } }
private void Update() { var textOffset = new Vector2(Mathf.Abs(this.Text.rectTransform.anchoredPosition.x), Mathf.Abs(this.Text.rectTransform.anchoredPosition.y)); this.Image.rectTransform.sizeDelta = this.Text.bounds.size.xy() + textOffset + this.SizeOffset; var pos = InputCtrl.MousePosition; pos = new Vector2(FunctionExtension.Remap(pos.x, 0f, Screen.width, 0f, 1920f), FunctionExtension.Remap(pos.y, 0f, Screen.height, 0f, 1080f)); this.RectTransform.anchoredPosition = pos + this.Offset + Vector2.up * this.Image.rectTransform.sizeDelta.y; }
/** * Private constructor used for function cloning. * * @param function the function, which is going * to be cloned. */ private Function(Function function) : base(Function.TYPE_ID) { functionName = function.functionName; description = function.description; parametersNumber = function.parametersNumber; functionExpression = function.functionExpression.clone(); functionBodyType = function.functionBodyType; if (functionBodyType == BODY_EXTENDED) { functionExtension = function.functionExtension.clone(); } }
public FunctionExtension GetExtension(Function function) { var typeExt = GetExtension(function.DeclaringType); FunctionExtension result; if (!typeExt.MethodExtensions.TryGetValue(function.Prototype.MasterDefinition, out result)) { result = new FunctionExtension(function.Source, function, 0, Compiler.NameResolver.GetUsings(function.DeclaringType, function.Source)); typeExt.MethodExtensions[function] = result; } return(result); }
/** * Constructor for function definition based on * your own source code - this is via implementation * of FunctionExtension interface. * * @param functionName Function name * @param functionExtension Your own source code */ public Function(String functionName, FunctionExtension functionExtension) : base(Function.TYPE_ID) { if (mXparser.regexMatch(functionName, ParserSymbol.nameOnlyTokenRegExp)) { this.functionName = functionName; functionExpression = new Expression("{body-ext}"); parametersNumber = functionExtension.getParametersNumber(); description = ""; this.functionExtension = functionExtension; functionBodyType = BODY_EXTENDED; } else { parametersNumber = 0; description = ""; functionExpression = new Expression(""); functionExpression.setSyntaxStatus(SYNTAX_ERROR_OR_STATUS_UNKNOWN, "[" + functionName + "]" + "Invalid function name, pattern not matches: " + ParserSymbol.nameTokenRegExp); } }
Statement CreateStatement(Function f, FunctionExtension ext) { var obj = CreateObject(ext.ImplementationSource, f, f.DeclaringType); var args = CreateArgumentList(ext.ImplementationSource, f); switch (ext.ImplementationType) { case ImplementationType.EmptyBody: return(new NoOp(ext.ImplementationSource)); case ImplementationType.Body: return(new ExternScope(ext.ImplementationSource, AttributeList.Empty, ext.ImplementationString, obj, args, ext.Scopes)); case ImplementationType.Expression: return(f.ReturnType.IsVoid ? (Statement) new ExternOp(ext.ImplementationSource, AttributeList.Empty, f.ReturnType, ext.ImplementationString, obj, args, ext.Scopes) : new Return(ext.ImplementationSource, new ExternOp(ext.ImplementationSource, AttributeList.Empty, f.ReturnType, ext.ImplementationString, obj, args, ext.Scopes))); } throw new InvalidOperationException(); }
public Argument(String argumentName, bool s, FunctionExtension _functionToCalculate) : base(Argument.TYPE_ID) { functionSpecified = true; functionExtensionToCalculate = _functionToCalculate; argumentExpression = new Expression(); if (mXparser.regexMatch(argumentName, ParserSymbol.nameOnlyTokenRegExp)) { this.argumentName = "" + argumentName; this.argumentValue = argumentValue; argumentType = FREE_ARGUMENT; } else { this.argumentValue = ARGUMENT_INITIAL_VALUE; argumentExpression.setSyntaxStatus(SYNTAX_ERROR_OR_STATUS_UNKNOWN, "[" + argumentName + "] " + "Invalid argument name, pattern not match: " + ParserSymbol.nameOnlyTokenRegExp); } argumentBodyType = BODY_RUNTIME; setSilentMode(); description = ""; }
/// <summary> /// 设置朝向位置 /// </summary> /// <param name="targetPos">朝向位置</param> private void SetLookRotation(Vector3 targetPos) { if (this.IsReleased) { return; } var direction = (targetPos - this.transform.position).SetValue(null, 0, null); var distance = direction.magnitude; if (distance < this.DisplayDistance)// 距离过近则不显示效果 { SetRendererEnabled(false); return; } else { SetRendererEnabled(true); } this.transform.rotation = Quaternion.LookRotation(direction); this.Contrller.localPosition = this.Contrller.localPosition.SetValue(z: FunctionExtension.Remap(distance, this.RemapDistance)); }
private void Start() { var width = 1024; var height = 1024; this.tex = new Texture2D(width, height); this.Renderer.material.mainTexture = this.tex; for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { var h = ((float)y / height); var xF = (float)x / width; var s = FunctionExtension.Remap(xF, 0.5f, 1f, 1, 0f); var v = FunctionExtension.Remap(xF, 0.0f, 0.5f, 0f, 1f); if (xF < 0.5f) { s = 1f; } else if (xF > 0.5f) { v = 1f; } else { s = v = 1f; } var color = Color.HSVToRGB(h, s, v); this.tex.SetPixel(x, y, color); } } this.tex.Apply(); System.IO.File.WriteAllBytes($"{Application.dataPath}/ColorSpace", this.tex.EncodeToPNG()); }
void CompileMethod(UxlMethod uxl, DataType dt, TypeExtension typeExt, Namescope[] typeScopes) { if (!Test(uxl.Condition)) { return; } var signatureString = uxl.Signature.String; var colonIndex = signatureString.MacroIndexOf(':'); string returnTypeString = null; if (colonIndex != -1) { returnTypeString = signatureString.Substring(colonIndex + 1); signatureString = signatureString.Substring(0, colonIndex); } var entity = _ilf.GetEntity(uxl.Signature.Source, signatureString, typeScopes); if (entity is InvalidType) { return; } if (!(entity is Function)) { Log.Error(uxl.Signature.Source, ErrorCode.E0000, uxl.Signature.String.Quote() + " is not a method signature"); return; } var method = entity as Function; var methodScopes = GetMethodScopes(method, typeScopes); if (returnTypeString != null) { var rt = _ilf.GetEntity(uxl.Signature.Source, returnTypeString, methodScopes); if (!(rt is InvalidType) && method.ReturnType != rt) { Log.Error(uxl.Signature.Source, ErrorCode.E0000, "Inconsistent return type for " + method.Quote() + " (" + method.ReturnType + ")"); } } else if (!method.ReturnType.IsVoid) { Log.Error(uxl.Signature.Source, ErrorCode.E0000, "Requiring return type for " + method.Quote() + " (" + method.ReturnType + ")"); } if (!method.HasAttribute(_ilf.Essentials.TargetSpecificImplementationAttribute) && !method.IsIntrinsic) { Log.Error(uxl.Signature.Source, ErrorCode.E0000, method.Quote() + " cannot be extended because it does not specify " + _ilf.Essentials.TargetSpecificImplementationAttribute.AttributeString); } if (dt.MasterDefinition != method.DeclaringType.MasterDefinition) { Log.Error(uxl.Signature.Source, ErrorCode.E0000, method.Quote() + " cannot be extended from outside its declaring type " + method.DeclaringType.Quote()); } if (!Test(uxl.Condition)) { return; } var methodExt = new FunctionExtension(uxl.Signature.Source, method, uxl.Disambiguation, methodScopes); Apply("Method", method, methodExt, typeExt.MethodExtensions); foreach (var impl in uxl.Implementations) { if (!Test(impl.Condition)) { continue; } if (!methodExt.HasImplementation || methodExt.IsDefaultImplementation && !impl.IsDefault) { methodExt.SetImplementation(impl.Body.Source ?? impl.Source, impl.Type, impl.Body.String, impl.IsDefault); } else if (methodExt.IsDefaultImplementation || !impl.IsDefault) { Log.Error(impl.Source, ErrorCode.E0000, "An implementation is already provided for " + method.Quote()); } } foreach (var e in uxl.Elements) { string key; if (!TryGetKey(e, out key) || !Test(e.Condition)) { continue; } if (e.Type == UxlElementType.Set && _root.MethodPropertyDefinitions.Contains(key)) { Apply("Set", key, new Element(e.Value.Source, e.Value.String, e.Disambiguation, methodScopes), methodExt.Properties); } else { CompileTypeElement(methodExt, "Method", key, e, methodScopes); } } CompileFiles(typeExt, uxl); }
public void SetSE(float value) { this.Mixer.SetFloat("SEvolume", FunctionExtension.Remap(value, 0f, 1f, this.VolumeLimit.x, this.VolumeLimit.y)); }
public void SetBrightness(float value) { this.Exposure.keyValue.value = FunctionExtension.Remap(value, 0f, 1f, 0f, 2f); }
public void Open() { this.gameObject.SetActive(true); // 解像度 { var rs = new List <string>(); var index = 0; for (var i = 0; i < this.Resolutions.Count; i++) { rs.Add($"{this.Resolutions[i].width}x{this.Resolutions[i].height}"); if (this.Resolutions[i].Equal(Screen.currentResolution)) { index = i; } } this.ResolutionDropdown.ClearOptions(); this.ResolutionDropdown.AddOptions(rs); this.ResolutionDropdown.value = index; } this.FullScreen.isOn = Screen.fullScreen; // 垂直同步 switch (QualitySettings.vSyncCount) { case 0: this.VSync30.isOn = false; this.VSync60.isOn = false; break; case 1: this.VSync30.isOn = false; this.VSync60.isOn = true; break; case 2: this.VSync30.isOn = true; this.VSync60.isOn = false; break; default: break; } // 画质 { var qs = new List <string>(QualitySettings.names); this.QualityDropdown.ClearOptions(); this.QualityDropdown.AddOptions(qs); this.QualityDropdown.value = QualitySettings.GetQualityLevel(); } this.BrightnessSlider.value = FunctionExtension.Remap(this.Exposure.keyValue.value, 0f, 2f, 0f, 1f); this.tempBrightness = this.BrightnessSlider.value; var volume = 0f; this.Mixer.GetFloat("BGMvolume", out volume); this.BGMSlider.value = FunctionExtension.Remap(volume, this.VolumeLimit.x, this.VolumeLimit.y, 0f, 1f); this.tempBGM = this.BGMSlider.value; volume = 0f; this.Mixer.GetFloat("SEvolume", out volume); this.SESlider.value = FunctionExtension.Remap(volume, this.VolumeLimit.x, this.VolumeLimit.y, 0f, 1f); this.tempSE = this.SESlider.value; }