private static void ExportScheme_Area(LightingEffect scheme) { if (scheme == null) { return; } LightingEffect_Area areaScheme = scheme as LightingEffect_Area; if (areaScheme == null) { return; } //Area string startTick = areaScheme.effectStartTick.ToString(); string intervalTick = areaScheme.effectIntervalTick.ToString(); string subEffectID = areaScheme.subEffectID.ToString(); string posBindBone = areaScheme.posBindBone; string customOffset = areaScheme.customOffset.x + ";" + areaScheme.customOffset.y + ";" + areaScheme.customOffset.z; string projOnGround = (areaScheme.projectOnGround ? 1 : 0).ToString(); string extentToMaxDis = (areaScheme.extentToMaxDistance ? 1 : 0).ToString(); string effectCount = areaScheme.effectCount.ToString(); string effectTotalTick = areaScheme.effectTotalTick.ToString(); ExportSchemeInfo(areaScheme, startTick, intervalTick, subEffectID, posBindBone, customOffset, projOnGround, extentToMaxDis, effectCount, effectTotalTick); }
public void Load(string strFilePath) { ScpReader reader = new ScpReader(strFilePath, true); if (reader == null) { Trace.LogError("read scheme fail! file = " + strFilePath); return; } m_dicLightEffectNodeList.Clear(); if (AssetBundleManager.isOnRunTimeMode) { int nRecorderCount = reader.GetRecordCount(); for (int row = 0; row < nRecorderCount; row++) { int nType = reader.GetInt(row, (int)Column_Common.COL_CFGTYPE, 0); AddSchemeNode(nType, reader, row); } } else { UnityEngine.Object[] assets = AssetBundleManager.LoadAllAssetOnEditorFromPathInstance(editorModeAssetPath, typeof(LightingEffect)); foreach (UnityEngine.Object asset in assets) { LightingEffect ef = asset as LightingEffect; AddLightEffect(ef); } } }
public virtual void ClearData() { effectConfig = null; effectID = 0; ResHandleInstance = null; }
/// <summary> /// 这个光效是否可以创建 /// </summary> /// <param name="effect"></param> /// <param name="param"></param> private bool isCanCreateEffect(LightingEffect effect, LightEffectParam param) { if (!isValid) { return(false); } if (ClosedOptimiezed) { return(true); } //是single类型的,梁成说必须要创建 if (effect.bSingle) { return(true); } //只对绑定光效作这个效果 if (effect.GetEffectType() != LightingEffectConfigType.Bind) { return(true); } LightingEffect_Bind bindeffect = effect as LightingEffect_Bind; bool Reslut = isCanCreateEffect_Single(effect.nID, param.nSrcEntityID, bindeffect.bIgnoreSingleEffectOptimtized, param) /*&& * isCanCreateEffect_OnView(param.nSrcEntityID)*/; return(Reslut); }
public LightingEffect GetLightingEffect(int id) { LightingEffect ef = null; m_dicLightEffectNodeList.TryGetValue(id, out ef); return(ef); }
public string Parse(string filePath) { string output = ""; StreamReader file = new StreamReader(filePath); if (file != null) { while (!file.EndOfStream) { // First should be keys List <string> keys = new List <string>(); keys = getKeys(file); LightingEffect effect = GetLightingEffect(file); List <string> colors = new List <string>(); colors = GetColors(file); var colorCount = colors.Count; if (effect == LightingEffect.STATIC && colorCount != 1) { throw new InvalidDataException("INVALID : Static effects are single color only"); } else if (effect == LightingEffect.DISCO && colorCount != 3) { throw new InvalidDataException("INVALID : Disco effects need 3 colors"); } addConfigurationEntries(keys, effect, colors); } } return(output); }
public override void DoSaveAction() { LightingEffect ta = target as LightingEffect; LightingEffectFactory.LoadByEditor(ta.nID); Debug.Log("Applying changes on LightingEffect"); }
private static void ExportScheme_Camera(LightingEffect scheme) { if (scheme == null) { return; } LightingEffect_Camera camScheme = scheme as LightingEffect_Camera; if (camScheme == null) { return; } //cam string animOrgPos = ((int)camScheme.animationOrgPos).ToString(); string animOrgProjFloor = (camScheme.animationOrgProjectFloor ? 1 : 0).ToString(); string animMainCam = (camScheme.animationMainCamera ? 1 : 0).ToString(); string attackType = ((int)camScheme.attackType).ToString(); string effectRad = camScheme.effectRad.ToString(); string effectLiveTick = camScheme.effectLiveTick.ToString(); string delayTick = camScheme.delayTick.ToString(); string effectFinishTick = camScheme.effectFinishTick.ToString(); string recoverTrs = (camScheme.recoverTransform ? 1 : 0).ToString(); ExportSchemeInfo(camScheme, animOrgPos, animOrgProjFloor, animMainCam, attackType, effectRad, effectLiveTick, delayTick, effectFinishTick, recoverTrs); }
private void addConfigurationEntries(List <string> keys, LightingEffect effect, List <string> colors) { keys.Sort(); foreach (var key in keys) { m_keys[key] = new KeyConfiguration(key, effect, colors); } }
/// <summary> /// 创建光效 /// </summary> /// <param name="nID"></param> /// <param name="param"></param> /// <returns></returns> public LightingEffectBehavior CreateEffect(int nID, LightEffectParam param, bool isFromHero = false) { if (!isValid) { return(null); } if (nID <= 0) { return(null); } LightingEffectBehavior reslut = null; LightingEffect config = ASpeedGame.Data.Scheme.SchemeLightingEffect.Instance.GetLightingEffect(nID); if (!config) { Trace.Warning("LightingEffect creates failed. Id " + nID.ToString() + "has not loaded."); return(reslut); } //if(!SceneManager.Instance.isMainCity()) //{ // if (!FirstCachedEffectID.Contains(nID)) // { // if (!currentCachedEffectID.Contains(nID)) // { // FirstCachedEffectID.Add(nID); // Debug.LogWarning("创建了没有缓存的光效,ID:" + nID); // } // } //} if (!isCanCreateEffect(config, param)) { return(reslut); } RemovePreWarmEffectQueue(nID); Queue <LightingEffectBehavior> cacheList = null; if (!m_behaviorCacheTable.TryGetValue(nID, out cacheList)) { cacheList = new Queue <LightingEffectBehavior>(); m_behaviorCacheTable.Add(nID, new Queue <LightingEffectBehavior>()); } if (cacheList.Count > 0) { reslut = cacheList.Dequeue(); ResetBehavior(reslut); } else { reslut = CreateNewBehavior(nID, config.GetEffectType()); } reslut.FillData(config, param, GetResourceHandleAsync(nID, reslut.OnResourcesLoadFinish), AllocBehaviorTransformAgent()); reslut.SetValid(); PushToEntityEffectTable(reslut); return(reslut); }
public override void FillData(LightingEffect effectConfig, LightEffectParam param, LightingEffectResHandleInstance instance, Transform transformAgent) { base.FillData(effectConfig, param, instance, transformAgent); this.wardConfig = effectConfig as LightingEffect_Ward; if (!wardConfig && effectConfig) { Debug.LogWarning(effectConfig.nID + "配置不匹配,创建光效失败---" + GetType().ToString()); } }
public void Clear() { m_effect_ReplaceAnimation = null; m_effectNode = null; m_effectPrefab = null; m_effectConfig = null; m_effectPrefabTransform = null; m_EffectID = -1; }
public virtual void FillData(LightingEffect effectConfig, LightEffectParam param, LightingEffectResHandleInstance instance, Transform transformAgent) { this.effectConfig = effectConfig; effectID = effectConfig.nID; this.effectParam = param; this.ResHandleInstance = instance; this.behaviorTransformAgent = transformAgent; ResHandlePlayData.Clear(); }
private static void ExportSchemeInfo(LightingEffect baseScheme, params string[] info) { StringBuilder sb = new StringBuilder(); string effectCfgType = ((int)baseScheme.GetEffectType()).ToString(); sb.Append(effectCfgType + ','); string nID = baseScheme.nID.ToString(); sb.Append(nID + ','); string assetGuid = baseScheme.AssetGUID; sb.Append(assetGuid + ','); string desc = baseScheme.strDesc; sb.Append(desc + ','); string global = (baseScheme.bGlobal ? 1 : 0).ToString(); sb.Append(global + ','); string single = (baseScheme.bSingle ? 1 : 0).ToString(); sb.Append(single + ','); string recovereffect = (baseScheme.bRecoverSingleEffect ? 1 : 0).ToString(); sb.Append(recovereffect + ','); string useSpeedScale = (baseScheme.bUseSpeedScale ? 1 : 0).ToString(); sb.Append(useSpeedScale + ','); string ignoreEffOpt = (baseScheme.bIgnoreSingleEffectOptimtized ? 1 : 0).ToString(); sb.Append(ignoreEffOpt + ','); string enableDisOpt = (baseScheme.EnableDistanceOptimtized ? 1 : 0).ToString(); sb.Append(enableDisOpt + ','); string closeWhenDead = (baseScheme.CloseWhenDead ? 1 : 0).ToString(); sb.Append(closeWhenDead + ','); string effectType = ((int)baseScheme.effectType).ToString(); sb.Append(effectType + ','); foreach (string s in info) { sb.Append(s); sb.Append(','); } if (sb != null) { WriteScheme(sb.ToString()); } }
public bool CheckGolbalEffect(int nID) { if (!isValid) { return(false); } LightingEffect reslut = ASpeedGame.Data.Scheme.SchemeLightingEffect.Instance.GetLightingEffect(nID); if (!reslut) { return(false); } return(reslut.bGlobal); }
public bool IsSingleEffect(int nID) { if (nID <= 0) { return(false); } LightingEffect ef = ASpeedGame.Data.Scheme.SchemeLightingEffect.Instance.GetLightingEffect(nID); if (!ef) { return(false); } return(ef.bSingle); }
void AddLightEffect(LightingEffect lightingEffect) { if (m_dicLightEffectNodeList == null || lightingEffect == null) { return; } if (m_dicLightEffectNodeList.ContainsKey(lightingEffect.nID)) { Trace.LogWarning("配置表ID重复!ID:" + lightingEffect.nID + " File = " + schemeFileName); return; } m_dicLightEffectNodeList.Add(lightingEffect.nID, lightingEffect); }
public LightingEffect Parse(string line) { string tempLine = line.ToUpper(); LightingEffect effect = LightingEffect.UNKNOWN; if (Enum.IsDefined(typeof(LightingEffect), tempLine)) { effect = (LightingEffect)Enum.Parse(typeof(LightingEffect), tempLine); } else { throw new InvalidDataException("INVALID : Invalid lighting effect input"); } return(effect); }
private static void ExportScheme_Sound(LightingEffect scheme) { if (scheme == null) { return; } LightingEffect_Sound soundScheme = scheme as LightingEffect_Sound; if (soundScheme == null) { return; } //sound string sound = soundScheme.soundID.ToString(); ExportSchemeInfo(soundScheme, sound); }
private static void ExportScheme_AniReplace(LightingEffect scheme) { if (scheme == null) { return; } LightingEffect_AnimationReplace aniReplaceScheme = scheme as LightingEffect_AnimationReplace; if (aniReplaceScheme == null) { return; } //animationReplace string startTick = aniReplaceScheme.nStartTick.ToString(); string endTick = aniReplaceScheme.nEndTick.ToString(); ExportSchemeInfo(aniReplaceScheme, startTick, endTick); }
public void Clear() { foreach (LightingEffectResHandleInstance instance in m_AllInstanceNode) { GameObject temp = instance.effectPrefab; if (!ResNode.isNullOrEmpty(prefabResNode)) { prefabResNode.DestroyInstanceRes(ref temp); } instance.Clear(); } m_CacheList.Clear(); m_AllInstanceNode.Clear(); effectConfig = null; prefabResNode = null; ReferenceCount = 0; isValid = false; stage = loadingStage.Stage_Invalid; currCacheTime = 0.0f; }
void FillBaseData(LightingEffect baseEffect, ScpReader reader, int row) { baseEffect.nID = reader.GetInt(row, (int)Column_Common.COL_ID, 0); baseEffect.AssetGUID = reader.GetString(row, (int)Column_Common.COL_GUID, ""); baseEffect.strDesc = reader.GetString(row, (int)Column_Common.COL_DESC, ""); baseEffect.bGlobal = reader.GetInt(row, (int)Column_Common.COL_GLOBAL, 0) > 0 ? true : false; baseEffect.bSingle = reader.GetInt(row, (int)Column_Common.COL_SINGLE, 0) > 0 ? true : false; baseEffect.bRecoverSingleEffect = reader.GetInt(row, (int)Column_Common.COL_RECOVEREFFECT, 0) > 0 ? true : false; baseEffect.bUseSpeedScale = reader.GetInt(row, (int)Column_Common.COL_SPEEDSCALE, 0) > 0 ? true : false; baseEffect.bIgnoreSingleEffectOptimtized = reader.GetInt(row, (int)Column_Common.COL_IGNOREEFFECTOPTIMIZED, 0) > 0 ? true : false; baseEffect.EnableDistanceOptimtized = reader.GetInt(row, (int)Column_Common.COL_ENABLEDISTANCEOPTIMIZED, 0) > 0 ? true : false; baseEffect.CloseWhenDead = reader.GetInt(row, (int)Column_Common.COL_CLOSEWHENDEAD, 0) > 0 ? true : false; int effectType = reader.GetInt(row, (int)Column_Common.COL_EFFECTTYPE, 0); if (Enum.IsDefined(typeof(LightingEffect.LightingEffectType), effectType)) { baseEffect.effectType = (LightingEffect.LightingEffectType)effectType; } }
private static void ExportScheme_Bind(LightingEffect scheme) { if (scheme == null) { return; } LightingEffect_Bind bindScheme = scheme as LightingEffect_Bind; if (bindScheme == null) { return; } //bind string createOutScreen = (bindScheme.bCreateOutsideScreen ? 1 : 0).ToString(); string scale = bindScheme.scale.ToString(); string startTick = bindScheme.effectStartTick.ToString(); string liveTick = bindScheme.effectLiveTick.ToString(); string dispearTick = bindScheme.effectDispearTick.ToString(); string posBindBone = bindScheme.posBindBone; string posOffset = bindScheme.posOffset.x + ";" + bindScheme.posOffset.y + ";" + bindScheme.posOffset.z; string rotBinBone = bindScheme.rotationBindBone; string rotOffset = bindScheme.rotationOffset.x + ";" + bindScheme.rotationOffset.y + ";" + bindScheme.rotationOffset.z; string faceToCam = (bindScheme.faceToCamera ? 1 : 0).ToString(); string offsetToSurface = (bindScheme.offsetToSurface ? 1 : 0).ToString(); string bindType = ((int)bindScheme.bindType).ToString(); string faceAgnistTarget = (bindScheme.faceAganistTarget ? 1 : 0).ToString(); string projOnFloor = (bindScheme.bProjectOnFloor ? 1 : 0).ToString(); string faceToWalkingDir = (bindScheme.faceToWalkingDirection ? 1 : 0).ToString(); string notRotate = (bindScheme.bNotRotate ? 1 : 0).ToString(); string bindTargetToSrc = (bindScheme.bindTargetToSource ? 1 : 0).ToString(); string bindTargetBone = bindScheme.bindTargetBone; string triggerHitDetect = (bindScheme.triggerHitDetect ? 1 : 0).ToString(); string sound = bindScheme.SoundID.ToString(); string posBindwound = bindScheme.posBindWound; ExportSchemeInfo(bindScheme, createOutScreen, scale, startTick, liveTick, dispearTick, posBindBone, posOffset, rotBinBone, rotOffset, faceToCam, offsetToSurface, bindType, faceAgnistTarget, projOnFloor, faceToWalkingDir, notRotate, bindTargetToSrc, bindTargetBone, triggerHitDetect, sound, posBindwound); }
private static void ExportScheme_Ward(LightingEffect scheme) { if (scheme == null) { return; } LightingEffect_Ward wardScheme = scheme as LightingEffect_Ward; if (wardScheme == null) { return; } //ward string startTick = wardScheme.nStartTick.ToString(); string endTick = wardScheme.nEndTick.ToString(); string blockAllCreature = (wardScheme.blockAllCreature ? 1 : 0).ToString(); ExportSchemeInfo(wardScheme, startTick, endTick, blockAllCreature); }
private static void ExportScheme_Shadow(LightingEffect scheme) { if (scheme == null) { return; } LightingEffect_Shadow shadowScheme = scheme as LightingEffect_Shadow; if (shadowScheme == null) { return; } //shadow string startTick = shadowScheme.nStartTick.ToString(); string endTick = shadowScheme.nEndTick.ToString(); string startAlpha = shadowScheme.fStartAlpha.ToString(); string shadowMaintainTick = shadowScheme.nShadowMaintainTick.ToString(); string shadowFadeoutTick = shadowScheme.nShadowFadeoutTick.ToString(); string shadowIntervTick = shadowScheme.shadowIntervalTicks.ToString(); string shadowFrameTick = ""; for (int i = 0; i < shadowScheme.shadowFrameTicks.Length; i++) { shadowFrameTick += shadowScheme.shadowFrameTicks[i]; if (i != shadowScheme.shadowFrameTicks.Length - 1) { shadowFrameTick += ";"; } } string alphaAttName = shadowScheme.alphaAttributeName; string disableWeapon = (shadowScheme.DisableWeapon ? 1 : 0).ToString(); string alphaAttType = ((int)shadowScheme.alphaAttributeType).ToString(); string minDis = shadowScheme.minDistance.ToString(); ExportSchemeInfo(shadowScheme, startTick, endTick, startAlpha, shadowMaintainTick, shadowFadeoutTick, shadowIntervTick, shadowFrameTick, alphaAttName, disableWeapon, alphaAttType, minDis); }
private static void ExportScheme_Speed(LightingEffect scheme) { if (scheme == null) { return; } LightingEffect_Speed speedScheme = scheme as LightingEffect_Speed; if (speedScheme == null) { return; } //speed string startTick = speedScheme.nStartTick.ToString(); string endTick = speedScheme.nEndTick.ToString(); string globalSpeed = speedScheme.globalSpeed.ToString(); string animSpeed = speedScheme.animatorSpeed.ToString(); string effectRad = speedScheme.effectRad.ToString(); ExportSchemeInfo(speedScheme, startTick, endTick, globalSpeed, animSpeed, effectRad); }
private bool PreWarmEffect(int nID, int PreWarmCount) { if (m_allBehaviorTable.ContainsKey(nID)) { //Debug.LogWarning("光效已经加载,不需要缓存,ID:" + nID); return(false); } LightingEffect config = ASpeedGame.Data.Scheme.SchemeLightingEffect.Instance.GetLightingEffect(nID); if (!config) { Debug.LogWarning("光效加载失败,找不到配置,ID:" + nID); return(false); } LightingEffectResHandle handle = AllocResourcesHandle(nID); Queue <LightingEffectBehavior> list = null; if (!m_behaviorCacheTable.TryGetValue(nID, out list)) { list = new Queue <LightingEffectBehavior>(); m_behaviorCacheTable.Add(nID, list); } for (int i = 0; i < PreWarmCount; i++) { LightingEffectBehavior reslut = CreateNewBehavior(nID, config.GetEffectType()); LightingEffectResHandleInstance instance = GetResourceHandleAsync(nID, reslut.OnResourcesLoadFinish); handle.CacheInstance(instance, EffectCacheRoot.transform, CachePos); handle.Release();//缓存不需要保留引用 reslut.FillData(config, null, instance, null); list.Enqueue(reslut); } return(true); }
private void Load(KeyboardState keyboard, string file, params GroupType[] groups) { GroupType currentGroup = GroupType.None; Macro currentMacro = null; HashSet <Layer> currentLayers = new HashSet <Layer>(); string[] lines = File.ReadAllLines(file); for (int i = 0; i < lines.Length; i++) { string line = lines[i].Trim(); if (line.StartsWith("#")) { continue; } if (line.StartsWith("[")) { currentGroup = GroupType.None; currentLayers.Clear(); int endBrace = line.IndexOf(']'); if (endBrace > 1) { string fullGroupName = line.Substring(1, endBrace - 1).Trim(); string[] groupNames = null; string innerName = null; string[] innerNameSplitted = null; int openParenth = fullGroupName.IndexOf('('); int closeParenth = fullGroupName.IndexOf(')'); if (openParenth > 0 && closeParenth > openParenth) { innerName = fullGroupName.Substring(openParenth + 1, closeParenth - (openParenth + 1)); innerNameSplitted = innerName.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); innerName = innerNameSplitted.Length > 0 ? innerNameSplitted[0] : null; for (int j = 0; j < innerNameSplitted.Length; j++) { innerNameSplitted[j] = innerNameSplitted[j].Trim(); } if (!string.IsNullOrEmpty(innerName)) { innerName = innerName.Trim(); } groupNames = new string[] { fullGroupName.Substring(0, openParenth).Trim() }; } else { // This is for layers (not macro / lighting) groupNames = fullGroupName.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); for (int j = 0; j < groupNames.Length; j++) { groupNames[j] = groupNames[j].Trim(); } } foreach (string groupName in groupNames) { switch (groupName.ToLower()) { case "base": if (groups.Contains(GroupType.Layer)) { currentGroup = GroupType.Layer; currentLayers.Add(FindOrAddLayer(KeyboardLayer.Base, false)); } break; case "layer1": if (groups.Contains(GroupType.Layer)) { currentGroup = GroupType.Layer; currentLayers.Add(FindOrAddLayer(KeyboardLayer.Layer1, false)); } break; case "layer2": if (groups.Contains(GroupType.Layer)) { currentGroup = GroupType.Layer; currentLayers.Add(FindOrAddLayer(KeyboardLayer.Layer2, false)); } break; case "layer3": if (groups.Contains(GroupType.Layer)) { currentGroup = GroupType.Layer; currentLayers.Add(FindOrAddLayer(KeyboardLayer.Layer3, false)); } break; case "fnbase": if (groups.Contains(GroupType.Layer)) { currentGroup = GroupType.Layer; currentLayers.Add(FindOrAddLayer(KeyboardLayer.Base, true)); } break; case "fnlayer1": if (groups.Contains(GroupType.Layer)) { currentGroup = GroupType.Layer; currentLayers.Add(FindOrAddLayer(KeyboardLayer.Layer1, true)); } break; case "fnlayer2": if (groups.Contains(GroupType.Layer)) { currentGroup = GroupType.Layer; currentLayers.Add(FindOrAddLayer(KeyboardLayer.Layer2, true)); } break; case "fnlayer3": if (groups.Contains(GroupType.Layer)) { currentGroup = GroupType.Layer; currentLayers.Add(FindOrAddLayer(KeyboardLayer.Layer3, true)); } break; case "macro": if (groups.Contains(GroupType.Macro) && !string.IsNullOrEmpty(innerName)) { currentGroup = GroupType.Macro; currentMacro = new Macro(innerName); Macros[innerName] = currentMacro; if (innerNameSplitted.Length > 1) { ushort.TryParse(innerNameSplitted[1], out currentMacro.DefaultDelay); } if (innerNameSplitted.Length > 2) { if (!Enum.TryParse <MacroRepeatType>(innerNameSplitted[2], true, out currentMacro.RepeatType)) { currentMacro.RepeatType = MacroRepeatType.RepeatXTimes; } } if (innerNameSplitted.Length > 3) { byte.TryParse(innerNameSplitted[3], out currentMacro.RepeatCount); } if (innerNameSplitted.Length > 4) { bool.TryParse(innerNameSplitted[4], out currentMacro.UseTrailingDelay); } if (currentMacro.RepeatCount == 0) { // No point in having a macro which doesn't even run... currentMacro.RepeatCount = 1; } } break; case "lighting": if (groups.Contains(GroupType.Lighting) && !string.IsNullOrEmpty(innerName)) { currentGroup = GroupType.Lighting; LightingEffect lightingEffect = null; if (!LightingEffects.TryGetValue(innerName, out lightingEffect)) { lightingEffect = new LightingEffect(innerName); } if (lightingEffect.Load(keyboard)) { LightingEffects[innerName] = lightingEffect; for (int j = 1; j < innerNameSplitted.Length; j++) { KeyboardLayer layer; if (Enum.TryParse(innerNameSplitted[j], out layer)) { lightingEffect.Layers.Add(layer); } } } else { Program.Log("Failed to load lighting effect '" + innerName + "'"); } } break; case "nolighting": if (innerNameSplitted != null) { for (int j = 0; j < innerNameSplitted.Length; j++) { KeyboardLayer layer; if (Enum.TryParse(innerNameSplitted[j], out layer)) { NoLightingLayers.Add(layer); } } } else { NoLighting = true; } break; } } } } else { switch (currentGroup) { case GroupType.Layer: { string[] splitted = line.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries); if (splitted.Length > 1) { string[] keysSplittedSrc = splitted[0].Split(new char[] { '+' }, StringSplitOptions.RemoveEmptyEntries); string[] keysSplittedDst = splitted[1].Split(new char[] { '+' }, StringSplitOptions.RemoveEmptyEntries); uint srcValue = 0; uint dstValue = 0; foreach (string str in keysSplittedSrc) { if (str.StartsWith("0x")) { uint.TryParse(str, NumberStyles.HexNumber, null, out srcValue); } else { DriverValue value; if (Enum.TryParse(str, out value)) { srcValue = (uint)value; } } } if (srcValue != 0) { foreach (string str in keysSplittedDst) { if (str.StartsWith("0x")) { uint.TryParse(str, NumberStyles.HexNumber, null, out dstValue); } else if (str.ToLower().StartsWith("macro")) { int openParenth = str.IndexOf('('); int closeParenth = str.IndexOf(')'); if (openParenth > 0 && closeParenth > openParenth) { string macroName = str.Substring(openParenth + 1, closeParenth - (openParenth + 1)); Macro macro = GetMacro(macroName); if (macro != null) { Debug.Assert(macro.Id >= 0 && macro.Id <= byte.MaxValue); dstValue = (uint)(0x0A010000 + macro.Id); } else { Program.Log("Failed to find macro '" + macroName + "' bound to key " + (DriverValue)srcValue); } } } else { DriverValue value; if (Enum.TryParse(str, out value)) { switch (KeyValues.GetKeyType((uint)value)) { case DriverValueType.Key: // TODO: Extra validation (this only makes sense for modifiers) dstValue |= (uint)value; break; default: dstValue = (uint)value; break; } } } } foreach (Layer currentLayer in currentLayers) { currentLayer.Keys[srcValue] = dstValue; } } } } break; case GroupType.Macro: { string[] splitted = line.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries); if (splitted.Length > 1) { string[] keysSplitted = splitted[1].Split(new char[] { '+' }, StringSplitOptions.RemoveEmptyEntries); ushort delay = currentMacro.DefaultDelay; if (splitted.Length > 2) { if (!ushort.TryParse(splitted[2], out delay)) { delay = currentMacro.DefaultDelay; } } MacroKeyState[] states = null; switch (splitted[0].ToLower()) { case "press": states = new MacroKeyState[] { MacroKeyState.Down, MacroKeyState.Up }; break; case "down": states = new MacroKeyState[] { MacroKeyState.Down }; break; case "up": states = new MacroKeyState[] { MacroKeyState.Up }; break; } for (int j = 0; j < states.Length; j++) { MacroKeyState state = states[j]; for (int k = 0; k < keysSplitted.Length; k++) { string str = keysSplitted[k]; Macro.Action action = new Macro.Action(); action.State = state; if (j == states.Length - 1 && k == keysSplitted.Length - 1) { // Only set the delay on the last listed key for each macro line entry action.Delay = delay; } else { action.Delay = 0; } DriverValue value; if (Enum.TryParse(str, out value)) { switch (value) { case DriverValue.LCtrl: action.Type = MacroKeyType.Key; action.Modifier = DriverValueModifer.LCtrl; //action.KeyCode = (byte)DriverValueModifer.LCtrl; break; case DriverValue.LShift: action.Type = MacroKeyType.Key; action.Modifier = DriverValueModifer.LShift; //action.KeyCode = (byte)DriverValueModifer.LShift; break; case DriverValue.LAlt: action.Type = MacroKeyType.Key; action.Modifier = DriverValueModifer.LAlt; //action.KeyCode = (byte)DriverValueModifer.LAlt; break; case DriverValue.LWin: action.Type = MacroKeyType.Key; action.Modifier = DriverValueModifer.LWin; //action.KeyCode = (byte)DriverValueModifer.LWin; break; case DriverValue.RCtrl: action.Type = MacroKeyType.Key; action.Modifier = DriverValueModifer.RCtrl; //action.KeyCode = (byte)DriverValueModifer.RCtrl; break; case DriverValue.RShift: action.Type = MacroKeyType.Key; action.Modifier = DriverValueModifer.RShift; //action.KeyCode = (byte)DriverValueModifer.RShift; break; case DriverValue.RAlt: action.Type = MacroKeyType.Key; action.Modifier = DriverValueModifer.RAlt; //action.KeyCode = (byte)DriverValueModifer.RAlt; break; case DriverValue.RWin: action.Type = MacroKeyType.Key; action.Modifier = DriverValueModifer.RWin; //action.KeyCode = (byte)DriverValueModifer.RWin; break; case DriverValue.MouseLClick: action.Type = MacroKeyType.Mouse; action.KeyCode = (byte)DriverValueMouseButton.LButton; break; case DriverValue.MouseRClick: action.Type = MacroKeyType.Mouse; action.KeyCode = (byte)DriverValueMouseButton.RButton; break; case DriverValue.MouseMClick: action.Type = MacroKeyType.Mouse; action.KeyCode = (byte)DriverValueMouseButton.MButton; break; case DriverValue.MouseBack: action.Type = MacroKeyType.Mouse; action.KeyCode = (byte)DriverValueMouseButton.Back; break; case DriverValue.MouseAdvance: action.Type = MacroKeyType.Mouse; action.KeyCode = (byte)DriverValueMouseButton.Advance; break; default: action.Type = MacroKeyType.Key; action.KeyCode = (byte)KeyValues.GetShortDriverValue((uint)value); break; } } currentMacro.Actions.Add(action); } } } } break; } } } }
public RenderingShaders(GraphicsDevice device) { var fogStart = 0f; TransparentEffect = new BlockEffect() { // Texture = stillAtlas, VertexColorEnabled = true, World = Matrix.Identity, AlphaFunction = CompareFunction.Greater, ReferenceAlpha = 32, FogStart = fogStart, FogEnabled = false, // TextureEnabled = true }; TranslucentEffect = new BlockEffect() { //Texture = stillAtlas, VertexColorEnabled = true, World = Matrix.Identity, AlphaFunction = CompareFunction.Greater, ReferenceAlpha = 32, FogStart = fogStart, FogEnabled = false, //Alpha = 0.5f }; AnimatedEffect = new BlockEffect() { // Texture = Resources.Atlas.GetAtlas(0), VertexColorEnabled = true, World = Matrix.Identity, AlphaFunction = CompareFunction.Greater, ReferenceAlpha = 32, FogStart = fogStart, FogEnabled = false, // TextureEnabled = true }; AnimatedTranslucentEffect = new BlockEffect() { //Texture = Resources.Atlas.GetAtlas(0), VertexColorEnabled = true, World = Matrix.Identity, AlphaFunction = CompareFunction.Greater, ReferenceAlpha = 127, FogStart = fogStart, FogEnabled = false, Alpha = 0.5f }; OpaqueEffect = new BlockEffect() { // TextureEnabled = true, // Texture = stillAtlas, FogStart = fogStart, VertexColorEnabled = true, // LightingEnabled = true, FogEnabled = false, ReferenceAlpha = 249, AlphaFunction = CompareFunction.Always // AlphaFunction = CompareFunction.Greater, // ReferenceAlpha = 127 // PreferPerPixelLighting = false }; LightingEffect = new LightingEffect(device) { }; }
protected virtual void Start() { turretType = this.GetType(); level = isPrebuilt ? this.level : 1; //All Self Built Turrets are Level 1. PREBUILT TURRET LEVELS SHOULD BE SET IN THE PREFAB ITSELF investmentLevel = 0; manaReturnPerc = isPrebuilt ? 0 : 1; //If is prebuilt, Player should not be gaining any mana at the start. manaSys = FindObjectOfType <ManaSystem> (); meshCollider = GetComponent <MeshCollider> (); audioSource = GetComponentInChildren <AudioSource>(); //For now use Get Component in Children because the Prefabs are messy //Check if its bullets should travel in an arc if (turretType == typeof(Catapult)) { arcTravel = true; } xRotation = transform.eulerAngles.x; baseR = GetComponent <Renderer>(); turretR = turretGO.GetComponent <Renderer>(); ChangeMaterial(level); baseModel = GetComponent <MeshFilter> (); turretModel = turretGO.GetComponent <MeshFilter>(); //Set For Enemy Detection collider = GetComponent <CapsuleCollider> (); collider.isTrigger = true; enemies = new List <AITemplate> (); //Set range of turret depending on type //Can Set in Inspector if wanted collider.height = 10 / transform.localScale.x; //Find event manager eventManager = FindObjectOfType <EventsManager> (); SetValues(); manaLight = GetComponentInChildren <LightingEffect>(); manaLight.gameObject.transform.localPosition = turretValues.lightingPos; investmentParticle = null; //Set Center of Collider Based on the capsule collider's direction /*switch (collider.direction) * { * case 0: * collider.center = new Vector3 (-transform.position.y / transform.localScale.x, 0, 0); * break; * case 1: * collider.center = new Vector3 (0, -transform.position.y / transform.localScale.x, 0); * break; * case 2: * collider.center = new Vector3 (0, 0, -transform.position.y / transform.localScale.x); * break; * default: * collider.center = new Vector3 (0, -transform.position.y / transform.localScale.x, 0); * break; * }*/ collider.radius = (turretValues.range / 2) / gameObject.transform.localScale.x; //Set cooldown coolDown = 1 / turretValues.fireRate; if (faction == Faction.own) { ManaSystem.inst.audioLibrary.PlayAudio(ManaSystem.inst.audioLibrary.build, audioSource); } }