void Delegate_UserName(GUIBase_Widget inInstigator) { //Debug.Log("Delegate_UserName: "******"Internal error. Interaction has to be disabled if Keyboard is active"); return; } GUIBase_Button button = inInstigator.GetComponent <GUIBase_Button>(); if (button == null) { Debug.LogError("Internal error !!! "); return; } if (m_UserName == s_DefaultUserNameText) { m_UserNameButton.TextFieldText = string.Empty; Delegate_OnKeyboardClose(m_UserNameButton, string.Empty, false); } #if !UNITY_EDITOR && (UNITY_IPHONE || UNITY_ANDROID) // TODO move pLace holder into text database string default_text = (m_UserName != s_DefaultUserNameText) ? m_UserName : string.Empty; ShowKeyboard(button, GuiScreen.E_KeyBoardMode.Default, Delegate_OnKeyboardClose, default_text, "Enter username"); #endif }
void Delegate_Password(GUIBase_Widget inInstigator) { //Debug.Log("Delegate_Password: "******"Internal error. Interaction has to be disabled if Keyboard is active"); return; } GUIBase_Button button = inInstigator.GetComponent <GUIBase_Button>(); if (button == null) { Debug.LogError("Internal error !!! "); return; } if (m_PasswordHash == s_DefaultPasswordText || string.IsNullOrEmpty(m_PasswordButton.TextFieldText)) { m_PasswordButton.TextFieldText = string.Empty; Delegate_OnKeyboardClose(m_PasswordButton, string.Empty, false); } #if !UNITY_EDITOR && (UNITY_IPHONE || UNITY_ANDROID) // TODO move pLace holder into text database ShowKeyboard(button, GuiScreen.E_KeyBoardMode.Password, Delegate_OnKeyboardClose, string.Empty, "Enter password"); #endif }
void KillOldDecals() { float currTime = Time.time; uint numKilled = 0; for (int idx = m_Decals.Count - 1; idx >= 0; idx--) { if ((currTime - m_Decals[idx].m_SpawnTime) > m_Decals[idx].m_Duration) { if (m_Decals[idx].m_IsDrop) { MFDebugUtils.Assert(m_NumSpawnedDrops > 0); m_NumSpawnedDrops--; } else { MFDebugUtils.Assert(m_NumSpawnedSplashes > 0); m_NumSpawnedSplashes--; } m_Decals.RemoveAt(idx); numKilled++; } } if (numKilled > 0) { m_DecalsVersion++; } }
//------------------------------------------------------------------------------------------------------------------ void Delegate_CreateAccount(GUIBase_Widget inInstigator) { //Debug.Log("Delegate_Login: "); MFDebugUtils.Assert(inInstigator == m_CreateAccountButton.Widget); StartCoroutine(CreateAccount_Coroutine()); }
Vector2 GetHeavySplatterPos(int idx) { MFDebugUtils.Assert(idx < 6); switch (idx) { case 0: return(new Vector2(-1, 1)); case 1: return(new Vector2(0, 1)); case 2: return(new Vector2(1, 1)); case 3: return(new Vector2(-1, -1)); case 4: return(new Vector2(0, -1)); case 5: return(new Vector2(1, -1)); } return(new Vector2(0, 0)); }
public void ConsumableItemUsed(E_ItemID id) { int index = PlayerData.InventoryList.Items.FindIndex(p => p.ID == id); if (index < 0) { return; } PPIItemData itemData = PlayerData.InventoryList.Items[index]; MFDebugUtils.Assert(itemData.IsValid()); itemData.Count--; PlayerData.InventoryList.Items[index] = itemData; if (uLink.Network.isServer) { //SEND TO CLOUD !!!! ItemSettings settings = ItemSettingsManager.Instance.Get(id); CloudServices.GetInstance() .ModifyItem(PrimaryKey, PPIManager.ProductID, settings.GUID, "Count", itemData.Count.ToString(), CloudConfiguration.DedicatedServerPasswordHash); } }
void Awake() { m_Material = Resources.Load("effects/m_lightning_bolt", typeof(Material)) as Material; if (m_Material) { m_Material = Instantiate(m_Material) as Material; } if (!m_Material) { Debug.LogError("Cannot load lighting bolt material"); } MFDebugUtils.Assert(m_Material); InitMeshes(); Generate(); if (m_Material) { SetMaterialParams(); } }
// @see StrictCharacterCreator.uLink_OnSerializeNetworkView() void uLink_OnSerializeNetworkView(uLink.BitStream stream, uLink.NetworkMessageInfo info) { MFDebugUtils.Assert(stream.isReading); Vector3 pos = stream.ReadVector3(); Vector3 vel = stream.ReadVector3(); Vector3 FireDir = stream.ReadVector3(); byte quantBodyYaw = stream.ReadByte(); float bodyYaw = NetUtils.DequantizeAngle(quantBodyYaw, 8); Quaternion bodyRotation = Quaternion.Euler(0, bodyYaw, 0); Owner.BlackBoard.FireDir = Owner.BlackBoard.Desires.FireDirection = FireDir; // on proxies, approximate fire place Owner.BlackBoard.Desires.FireTargetPlace = pos + FireDir * 10; if (Owner.IsAlive) { if (null != SmoothTransform) { double timestamp = SmoothTransform.GetTime(info); SmoothTransform.AddState(timestamp, pos, vel, bodyRotation); } else { SetTransform(pos, bodyRotation, vel); } } }
bool DoInit() { m_GameObj = new GameObject(); shader = Shader.Find("MADFINGER/PostFX/ExplosionFX"); if (!shader) { Debug.LogError("Unable to get ExplosionFX shader"); } MFDebugUtils.Assert(shader); if (!InitMeshes()) { return(false); } for (int i = 0; i < m_MaxWaves; i++) { m_FreeWaveEmitterSlots.Push(i); } m_GameObj.SetActive(false); return(true); }
void InitMeshes() { gameObject.AddComponent <MeshFilter>(); gameObject.AddComponent <MeshRenderer>(); m_MeshFilter = (MeshFilter)GetComponent(typeof(MeshFilter)); m_MeshRenderer = (MeshRenderer)GetComponent(typeof(MeshRenderer)); m_MeshRenderer.GetComponent <Renderer>().material = m_Material; m_MeshRenderer.GetComponent <Renderer>().enabled = true; m_MeshRenderer.GetComponent <Renderer>().shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off; m_MeshRenderer.GetComponent <Renderer>().receiveShadows = false; m_Mesh = m_MeshFilter.mesh; if (m_BloodOverlayMeshGameObj) { m_BloodOverlayMeshGOInst = Object.Instantiate(m_BloodOverlayMeshGameObj, Vector3.zero, Quaternion.identity) as GameObject; MFDebugUtils.Assert(m_BloodOverlayMeshGOInst); MFDebugUtils.Assert(m_BloodOverlayMeshGameObj.GetComponent <Renderer>()); m_BloodOverlayMeshGOInst.transform.eulerAngles = new Vector3(45, 45, 45); } }
public static void PreloadResources() { if (!MFExplosionPostFX.Instance) { Camera.main.gameObject.AddComponent <MFExplosionPostFX>(); MFDebugUtils.Assert(MFExplosionPostFX.Instance); } }
ulong CalcRendererKey(int queueIdx, int layoutId, Material mat) { MFDebugUtils.Assert(layoutId < 65536 && queueIdx < 65535); ulong res = ((ulong)mat.GetInstanceID() << 32) + ((ulong)layoutId << 16) + (ulong)queueIdx; return(res); }
void EnforceDataValidity() { const int MAX_EXPERIENCE = 100000000; const int MAX_MONEY = 100000000; const int MAX_GOLD = 100000000; bool dataCorrected = false; MFDebugUtils.Assert(IsValid); if (PlayerData.Params.Experience < 0 || PlayerData.Params.Experience > MAX_EXPERIENCE) { PlayerData.Params.Experience = 0; dataCorrected = true; } if (PlayerData.Params.Money < 0 || PlayerData.Params.Money > MAX_MONEY) { PlayerData.Params.Money = 10000; dataCorrected = true; } if (PlayerData.Params.Gold < 0 || PlayerData.Params.Gold > MAX_GOLD) { PlayerData.Params.Gold = 1000; dataCorrected = true; } // Cloud does not test/filter the weapon list and weapon slots // The main purpose of this check is to disallow cheaters to use the premium slot. We ignore // the check for the extra weapon slot because it is super-cheap and everyone can easily buy it. int validWeaponSlots = IsPremiumAccountActive ? 3 : 2; if (PlayerData.EquipList.Weapons.Count > validWeaponSlots) { PlayerData.EquipList.Weapons.RemoveAll(e => e.EquipSlotIdx >= validWeaponSlots); dataCorrected = true; } // Cloud does not test/filter the weapon list and weapon slots // The main purpose of this check is to disallow cheaters to use the premium slot. We ignore // the check for the extra item slot because it is super-cheap and everyone can easily buy it. int validItemSlots = IsPremiumAccountActive ? 3 : 2; if (PlayerData.EquipList.Items.Count > validItemSlots) { PlayerData.EquipList.Items.RemoveAll(e => e.EquipSlotIdx >= validItemSlots); dataCorrected = true; } if (dataCorrected) { Debug.LogWarning("Invalid PPI data detected for user " + PrimaryKey + "(" + Name + ")"); } }
void SetupLineSegmentRadial(int idx, Vector3 center, float radius, float angle, Matrix4x4 m) { int numSegments = m_MaxLineSegments; Vector3[] pts = new Vector3[numSegments + 1]; float dAngle = angle / numSegments; MFDebugUtils.Assert(idx < m_MaxLines); for (int i = 0; i < pts.Length; i++) { Vector4 currPt; currPt.x = radius * Mathf.Sin(i * dAngle); currPt.y = 0; currPt.z = radius * Mathf.Cos(i * dAngle); currPt.w = 1; pts[i] = m * currPt; } Vector3[] verts = m_Mesh.vertices; Vector3[] normals = m_Mesh.normals; Vector2[] uv = m_Mesh.uv; int segOffs = idx * m_MaxLineSegments * 4; float currU = 0; float du = 1.0f / numSegments; for (int i = 0; i < numSegments; i++) { int offs = segOffs + i * 4; Vector3 dir = pts[i + 1] - pts[i]; verts[offs] = pts[i]; uv[offs].x = currU; normals[offs++] = dir; verts[offs] = pts[i]; uv[offs].x = currU; normals[offs++] = dir; currU += du; dir = pts[(i + 2) % pts.Length] - pts[i + 1]; verts[offs] = pts[i + 1]; uv[offs].x = currU; normals[offs++] = dir; verts[offs] = pts[i + 1]; uv[offs].x = currU; normals[offs++] = dir; } m_Mesh.vertices = verts; m_Mesh.normals = normals; m_Mesh.uv = uv; }
// Owner is sending informations about its state to the server void LateUpdate() { MFDebugUtils.Assert(networkView.isMine); if (Owner.IsAlive) { SendMoveUpdateToServer(); } }
void Delegate_OnKeyboardClose(GUIBase_Button inInput, string inKeyboardText, bool inInputCanceled) { MFDebugUtils.Assert(m_EmailButton == inInput); m_Email = inKeyboardText.ToLower(); m_EmailButton.SetNewText(m_Email); UpdateMigrateButton(); }
void CreateCamFXInstance() { if (!MFExplosionPostFX.Instance) { Camera.main.gameObject.AddComponent <MFExplosionPostFX>(); MFDebugUtils.Assert(MFExplosionPostFX.Instance); } MFExplosionPostFX.Instance.enabled = true; }
void SetGlowShaderParams(int glowIdx, ScreenSpaceGlowEmitter glowInfo, Vector3 camDir, Vector3 camPos) { Vector3 ldir = glowInfo.transform.forward; Vector3 lpos = glowInfo.transform.position; Vector4 paramSet0 = lpos; Vector4 paramSet1 = glowInfo.m_Color * glowInfo.m_Intensity * Mathf.Pow(Mathf.Clamp01(Vector3.Dot(-camDir, ldir)), m_DirFadeoutStrength); Matrix4x4 glowParams = Matrix4x4.zero; Vector3 toViewer = camPos - lpos; float dist = toViewer.magnitude; toViewer.Normalize(); float dirFadeout = RemapValue(Mathf.Clamp01(Vector3.Dot(toViewer, ldir)), Mathf.Cos(glowInfo.m_ConeAngle * Mathf.Deg2Rad / 2), 1, 0, 1); float ndist = Mathf.Clamp01(dist / glowInfo.m_MaxVisDist); dirFadeout = Mathf.Pow(dirFadeout, glowInfo.m_DirIntensityFallof); m_GlowsIntensityMask[glowIdx] = dirFadeout * (1 - ndist * ndist); glowParams.SetRow(0, paramSet0); glowParams.SetRow(1, paramSet1); glowParams.SetRow(2, ldir); switch (glowIdx) { case 0: { material.SetMatrix("_Glow0Params", glowParams); } break; case 1: { material.SetMatrix("_Glow1Params", glowParams); } break; case 2: { material.SetMatrix("_Glow2Params", glowParams); } break; case 3: { material.SetMatrix("_Glow3Params", glowParams); } break; default: MFDebugUtils.Assert(false); break; } }
// server -> proxies // @see StrictCharacterOwner.uLink_OnSerializeNetworkViewOwner() void uLink_OnSerializeNetworkViewOwner(uLink.BitStream stream, uLink.NetworkMessageInfo info) { MFDebugUtils.Assert(stream.isWriting); if (Owner.IsInKnockdown) { stream.Write(m_Transform.position); stream.Write(m_Transform.rotation); stream.Write(velocity); } }
bool UpdateSettingsManagers() { JsonData data = JsonMapper.ToObject(m_ShopItemsJSON); bool res = true; if (data != null && data.IsArray) { Dictionary <int, JsonData> jsonObjectsByGUID = new Dictionary <int, JsonData>(); for (int i = 0; i < data.Count; i++) { JsonData item = data[i]; int guid = -1; try { JsonData GUID = item["GUID"]; guid = (int)GUID; } catch { continue; } MFDebugUtils.Assert(guid != -1); if (jsonObjectsByGUID.ContainsKey(guid)) { Debug.LogError("Multiply defined shop item GUID found : " + guid); continue; } jsonObjectsByGUID.Add(guid, item); } res &= FundSettingsManager.Instance.UpdateFromJSONDesc(jsonObjectsByGUID); res &= HatSettingsManager.Instance.UpdateFromJSONDesc(jsonObjectsByGUID); res &= ItemSettingsManager.Instance.UpdateFromJSONDesc(jsonObjectsByGUID); res &= SkinSettingsManager.Instance.UpdateFromJSONDesc(jsonObjectsByGUID); res &= UpgradeSettingsManager.Instance.UpdateFromJSONDesc(jsonObjectsByGUID); res &= WeaponSettingsManager.Instance.UpdateFromJSONDesc(jsonObjectsByGUID); res &= TicketSettingsManager.Instance.UpdateFromJSONDesc(jsonObjectsByGUID); res &= AccountSettingsManager.Instance.UpdateFromJSONDesc(jsonObjectsByGUID); res &= BundleSettingsManager.Instance.UpdateFromJSONDesc(jsonObjectsByGUID); } else { Debug.LogError("Error parsing shop settings"); } return(res); }
void Update() { MFDebugUtils.Assert(!networkView.isMine); if (null != SmoothTransform) { if (SmoothTransform.UpdateCustom()) { SetTransform(SmoothTransform.Position, SmoothTransform.Rotation, SmoothTransform.Velocity); } } }
// ################################################################################################################# // ### Delegates ################################################################################################# void Delegate_OK(GUIBase_Widget inInstigator) { //Debug.Log("Delegate_OK: "); MFDebugUtils.Assert(inInstigator == m_OKButton.Widget); if (m_IsForPassword) { SendResult(E_PopupResultCode.Ok); } else { StartCoroutine(PasswordRecoveryRequest_Coroutine()); } }
// server -> proxies // @see StrictCharacterProxy.uLink_OnSerializeNetworkView() void uLink_OnSerializeNetworkView(uLink.BitStream stream, uLink.NetworkMessageInfo info) { MFDebugUtils.Assert(stream.isWriting); stream.WriteVector3(m_Transform.position); stream.WriteVector3(velocity); //stream.Write( m_Transform.rotation ); // kdyz se posila jenom "rotation", tak nefunguje spravne proxy, kdyz se ignoruje server update stream.WriteVector3(Owner.BlackBoard.FireDir); Quaternion bodyRotation = m_Transform.rotation; byte quantBodyYaw = (byte)NetUtils.QuantizeAngle(bodyRotation.eulerAngles.y, 8); stream.WriteByte(quantBodyYaw); }
// ################################################################################################################# // ### Delegates ################################################################################################# void Delegate_OK(GUIBase_Widget inInstigator) { //Debug.Log("Delegate_OK: "); MFDebugUtils.Assert(inInstigator == m_OKButton.Widget); if (string.IsNullOrEmpty(Username) == false || string.IsNullOrEmpty(PrimaryKey) == false) { StartCoroutine(AddNewFriend_Coroutine()); } else { Owner.Back(); } }
private void CreateToolData() { MFDebugUtils.Assert(m_ToolsData == null); MFDebugUtils.Assert(m_ValidScene == true); GameObject game = GameObject.Find("hra"); MFDebugUtils.Assert(game != null); m_ToolsData = game.GetComponent <LevelToolsData>(); MFDebugUtils.Assert(m_ToolsData == null); if (m_ToolsData == null) { m_ToolsData = game.AddComponent <LevelToolsData>() as LevelToolsData; } }
void Delegate_OnKeyboardClose(GUIBase_Button inInput, string inKeyboardText, bool inInputCanceled) { MFDebugUtils.Assert(m_NameButton == inInput); m_UserName = inKeyboardText.ToLower(); if (m_IsForPassword) { m_NameButton.SetNewText(new string('*', GuiBaseUtils.FixNameForGui(m_UserName).Length)); } else { m_NameButton.SetNewText(GuiBaseUtils.FixNameForGui(m_UserName)); } UpdateOKButton(); }
void Delegate_Login(GUIBase_Widget inInstigator) { //Debug.Log("Delegate_Login: "******"Internal error. Login button has to be disabled if Login Data are not valid"); //PPIManager.Instance.DummyAuthentication_TESTING = true; //PPIManager.Instance.AuthenticateLocalUser(); } }
// ================================================================================================== // === INTERNAL ===================================================================================== void ClientExplode() { // Check if this explosion is MFDebugUtils.Assert(m_Exploded == false); if (GetComponent <AudioSource>() != null && GetComponent <AudioSource>().clip != null) { GetComponent <AudioSource>().Play(); } Frustum.SetupCamera(GameCamera.Instance); Frustum.E_Location loc = Frustum.PointInFrustum(Position); if (loc == Frustum.E_Location.Outside) //do not spawn the projectile if it's not visible at all { return; } // Run particles only when explosion is longer as is m_ParticleCriticalDistance. // Reason : Particles from explosion are full scree when explosion is too near, and // full-screen particles are too slow. So we don't run them. #if !UNITY_EDITOR if (m_ParticleCriticalDistance < 0 || Camera.main == null || Vector3.Magnitude(Camera.main.transform.position - Position) > m_ParticleCriticalDistance) #endif { // Run all particles... foreach (ParticleSystem em in m_Emitters) { if (null != em) { em.Play(); } } } //if (audio != null && audio.clip != null) // audio.Play(); // Do screen fx... if (m_GenerateWaveFX && CamExplosionFXMgr.Instance) { GenerateWaveFX(); } }
// Called by camera to apply image effect void OnRenderImage(RenderTexture source, RenderTexture destination) { MFDebugUtils.Assert(shader); //Debug.Log("tt"); if (material) { Matrix4x4 Msat = CalcSaturationMatrix(Saturation); Matrix4x4 Mc = ColorContrastMatrix(Contrast); Matrix4x4 Mo = ColorOffsetMatrix(R_offs, G_offs, B_offs); Matrix4x4 Mb = ColorOffsetMatrix(Brightness - 1, Brightness - 1, Brightness - 1); Matrix4x4 m = Mb * Mc * Msat * Mo; material.shader = shader; material.SetMatrix("_ColorMatrix", m.transpose); } Graphics.Blit(source, destination, material); }
public virtual void CheckDataConsistency() { if (m_DefaultFont == null) { Debug.LogError("Default font is not assigned", this); } MFDebugUtils.Assert(m_DefaultFont != null); // verify that default font name is not used in additional fonts. List <FontSetup> result; result = m_Fonts.FindAll(font => font.m_FontName == m_DefaultFontName); if (result != null && result.Count > 0) { Debug.LogError(string.Format("'{0}' is reserved name and can't be used for other fonts", m_DefaultFontName), this); } if (m_DefaultFontName != DefaultFontName_Static) { result = m_Fonts.FindAll(font => font.m_FontName == DefaultFontName_Static); if (result != null && result.Count > 0) { Debug.LogError(string.Format("'{0}' is reserved name and can't be used for other fonts", DefaultFontName_Static), this); } } // and now check that all names are unique... foreach (FontSetup setup in m_Fonts) { if (setup.m_Default.m_Font == null) { Debug.LogError(string.Format("Font setup [{0}] doesn't have assigned default font", setup.m_FontName), this); } result = m_Fonts.FindAll(font => font.m_FontName == setup.m_FontName); if (result.Count != 1) { Debug.LogError(string.Format("Font name {0} isn't unique [{1}]", setup.m_FontName, result.Count), this); } } }