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); } }
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()); }
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 }
// ========================================================================================================================= // === debug =============================================================================================================== #if UNITY_EDITOR void Debug_GenerateRandomFriends(bool inActive) { if (inActive == true) { m_Friends.Clear(); for (int i = 0; i < 10; i++) { FriendInfo friend = new FriendInfo(); friend.PrimaryKey = MFDebugUtils.GetRandomString(Random.Range(5, 12)); //friend.m_Level = Random.Range(1,20); //friend.m_Missions = Random.Range(0,200); friend.LastOnlineDate = 0; //MiscUtils.RandomValue( new string[] {"unknown", "yesterday", "tomorrow"}); m_Friends.Add(friend); } } else { m_PendingFriends.Clear(); for (int i = 0; i < 10; i++) { PendingFriendInfo friend = new PendingFriendInfo(); friend.PrimaryKey = MFDebugUtils.GetRandomString(Random.Range(5, 12)); friend.AddedDate = GuiBaseUtils.DateToEpoch(CloudDateTime.UtcNow); if (Random.Range(0, 2) == 0) { // create dummy message, for testing gui behavior... friend.CloudCommand = MFDebugUtils.GetRandomString(Random.Range(512, 512)); } m_PendingFriends.Add(friend); } } }
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); }
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 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 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; }
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 + ")"); } }
// 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; }
// MONOBEHAVIOUR INTERFACE void Awake() { Widget = GetComponent <GUIBase_Widget>(); if (Widget == null) { Debug.LogWarning("There is NOT any widget specified for MultiSprite '" + MFDebugUtils.GetFullName(gameObject) + "'!"); return; } Widget.CreateMainSprite = 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); } }
IEnumerator GenerateRandomText_Coroutine(int inMinSize, int inMaxSize) { while (true) { yield return(new WaitForSeconds(Random.Range(1, 3))); yield return(new WaitForFixedUpdate()); SetNewText(MFDebugUtils.GetRandomString(Random.Range(inMinSize, inMaxSize))); } }
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); } } }
// 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(); } }
// ################################################################################################################# // ### 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()); } }
//--------------------------------------------------------- public bool GenerateRunTimeData() { bool regenerated = IsDataRegenerationNeaded(); if (regenerated) { //RebuildRuntimeData(); if (font == null) { Debug.LogWarning("GUIBase_Label have not a font assigned " + MFDebugUtils.GetFullName(gameObject)); } else { GUIBase_Widget widget = GetComponent <GUIBase_Widget>(); m_TextDyn = null; m_TextIDGenerated = 0; if (m_TextID != 0) { m_TextDyn = m_AllowMultiline == true ? TextDatabase.instance[m_TextID] : TextDatabase.instance[m_TextID].Replace("\n", " "); #if UNITY_EDITOR if (m_TextDyn == "<UNKNOWN TEXT>") { Debug.Log("Invalid text id on gameobject " + gameObject.GetFullName()); } #endif m_TextIDGenerated = m_TextID; } #if UNITY_EDITOR m_ReloadCount = TextDatabase.instance.reloadCount; #endif Texture2D texture = fontTexture; float texHeight = texture.height; Vector2 textSize = GetTextSize(); widget.SetScreenSize(textSize.x, textSize.y * texHeight); #if UNITY_EDITOR m_AnchorPointGen = (int)m_AnchorPoint; m_AlignmentGen = (int)m_Alignment; m_LineSpaceGenerated = m_LineSpace2; m_UseFontExGen = useFontEx; #endif } } return(regenerated); }
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(); }