void MoveObject()
        {
            //!!!!?
            if (obj.Disposed)
            {
                return;
            }

            if (dataToRestore.parent != obj.Parent)
            {
                var newRestoreData = new RestoreData();
                newRestoreData.parent      = obj.Parent;
                newRestoreData.insertIndex = obj.Parent.Components.IndexOf(obj);

                obj.Parent.RemoveComponent(obj, false);
                dataToRestore.parent.AddComponent(obj, dataToRestore.insertIndex);

                dataToRestore = newRestoreData;
            }
            else
            {
                var newRestoreData = new RestoreData();
                newRestoreData.parent      = dataToRestore.parent;
                newRestoreData.insertIndex = obj.Parent.Components.IndexOf(obj);

                dataToRestore.parent.Components.MoveTo(obj, dataToRestore.insertIndex);

                dataToRestore = newRestoreData;
            }
        }
Example #2
0
        public object GetDataFromJwt(ApiConfig.Options options, string jwt)
        {
            object obj = null;

            switch (options)
            {
            case ApiConfig.Options.SchoolRegistration:
                obj = new SchoolRegistrationInfo(
                    jwtSecurityToken.Claims.First(claim => claim.Type == ApiConfig.ClaimTypeLogin).Value,
                    jwtSecurityToken.Claims.First(claim => claim.Type == ApiConfig.ClaimTypePassword).Value,
                    jwtSecurityToken.Claims.First(claim => claim.Type == ApiConfig.ClaimTypeUserEmail).Value,
                    jwtSecurityToken.Claims.First(claim => claim.Type == ApiConfig.ClaimTypeSchoolName).Value,
                    jwtSecurityToken.Claims.First(claim => claim.Type == ApiConfig.ClaimTypeSchoolLocation).Value,
                    jwtSecurityToken.Claims.First(claim => claim.Type == ApiConfig.ClaimTypeSchoolEmail).Value,
                    jwtSecurityToken.Claims.First(claim => claim.Type == ApiConfig.ClaimTypeSchoolNumber).Value
                    );
                break;

            case ApiConfig.Options.Restore:
                obj = new RestoreData(
                    jwtSecurityToken.Claims.First(claim => claim.Type == ApiConfig.ClaimTypeUserEmail).Value,
                    jwtSecurityToken.Claims.First(claim => claim.Type == ApiConfig.ClaimTypeUserNewPassword).Value,
                    jwtSecurityToken.Claims.First(claim => claim.Type == ApiConfig.ClaimTypeUserNewPassword).Value
                    );
                break;
            }

            return(obj);
        }
Example #3
0
        public string GetJwt(ApiConfig.Options options, object obj)
        {
            List <Claim> claims = null;

            switch (options)
            {
            case ApiConfig.Options.SchoolRegistration:
                SchoolRegistrationInfo regInfo = obj as SchoolRegistrationInfo;
                claims = new List <Claim>
                {
                    new Claim(ApiConfig.ClaimTypeLogin, regInfo.Login),
                    new Claim(ApiConfig.ClaimTypePassword, regInfo.Password),
                    new Claim(ApiConfig.ClaimTypeUserEmail, regInfo.Email),
                    new Claim(ApiConfig.ClaimTypeSchoolName, regInfo.SchoolName),
                    new Claim(ApiConfig.ClaimTypeSchoolLocation, regInfo.SchoolLocation),
                    new Claim(ApiConfig.ClaimTypeSchoolEmail, regInfo.SchoolEmail != null ? regInfo.SchoolEmail : ""),
                    new Claim(ApiConfig.ClaimTypeSchoolNumber, regInfo.SchoolNumber),
                };
                break;

            case ApiConfig.Options.Restore:
                RestoreData rd = obj as RestoreData;
                claims = new List <Claim>
                {
                    new Claim(ApiConfig.ClaimTypeUserEmail, rd.Email),
                    new Claim(ApiConfig.ClaimTypeUserNewPassword, rd.NewPassword)
                };
                break;

            default:
                break;
            }

            DateTime now = DateTime.UtcNow;

            jwtSecurityToken = new JwtSecurityToken(
                issuer: ApiConfig.ISSUER,
                audience: ApiConfig.AUDIENCE,
                notBefore: now,
                claims: claims,
                expires: now.Add(TimeSpan.FromMinutes(ApiConfig.LIFETIME)),
                signingCredentials: new SigningCredentials(ApiConfig.GetSymmetricSecurityKey(), SecurityAlgorithms.HmacSha256));

            return(jwtSecurityTokenHandler.WriteToken(jwtSecurityToken));
        }
        public ActionResult Restore(RestoreData restoreData)
        {
            if (!dbUnit.UserAccountRepository.isExistByEmail(restoreData.Email))
            {
                return(BadRequest(HttpResponseMessages.EmailNotExist));
            }
            if (restoreData.NewPassword != restoreData.RepeatedNewPassword)
            {
                return(BadRequest(HttpResponseMessages.PasswordNotMatch));
            }
            if (restoreData.NewPassword.Length < 8 || restoreData.NewPassword.Length > 32)
            {
                return(BadRequest(HttpResponseMessages.BadPassword));
            }
            emailService.SendMessage(ApiConfig.Options.Restore, restoreData.Email, restoreData);

            return(Ok(HttpResponseMessages.RestoreCheckEmail));
        }
    //-------------------------------------------------------------------------
    protected void RestoreColliderData()
    {
        for (int index = 0; index < mDataToRestore.Length; ++index)
        {
            Transform restoreNode = this.transform.Find(mNodePaths[index]);

            MeshCollider collider = restoreNode.GetComponent <MeshCollider>();
            if (collider == null)
            {
                collider = restoreNode.gameObject.AddComponent <MeshCollider>();
            }
            collider.sharedMesh = null;
            RestoreData data = mDataToRestore[index];
            collider.sharedMesh             = data.mColliderMesh;
            collider.isTrigger              = data.mIsTrigger;
            collider.convex                 = data.mConvex;
            collider.sharedMaterial         = data.mSharedMaterial;
            collider.smoothSphereCollisions = data.mSmoothSphereCollisions;

            Transform referenceColliderNode        = restoreNode;
            bool      parentHoldsReferenceCollider = mIsSmoothMovesScaleAnimAppliedAtNode[index];
            if (parentHoldsReferenceCollider)
            {
                referenceColliderNode = restoreNode.transform.parent;
            }

            bool hasSmoothMovesCollider = referenceColliderNode.GetComponent <BoxCollider>();
            if (!hasSmoothMovesCollider)
            {
                hasSmoothMovesCollider = referenceColliderNode.GetComponent <SphereCollider>();
            }

            if (hasSmoothMovesCollider)
            {
                // copy the SmoothMoves collider's enabled state at runtime.
                AlphaMeshColliderCopyColliderEnabled copyStateComponent = restoreNode.GetComponent <AlphaMeshColliderCopyColliderEnabled>();
                if (copyStateComponent == null)
                {
                    copyStateComponent = restoreNode.gameObject.AddComponent <AlphaMeshColliderCopyColliderEnabled>();
                }
            }
        }
    }
        /// <summary>
        /// Add Details Data To Terrain
        /// </summary>
        /// <param name="terrain">A specific terrain</param>
        /// <param name="details">terrain's details</param>
        /// <param name="layersIndex">detail's layer</param>
        static void AddModificationData(Terrain terrain, int[,] details, int layersIndex)
        {
            RestoreData currentData;

            if (!restoreData.ContainsKey(terrain))
            {
                currentData = new RestoreData();
                restoreData.Add(terrain, currentData);
            }

            currentData = restoreData[terrain];

            if (currentData.details.ContainsKey(layersIndex))
            {
                return;
            }

            currentData.details.Add(layersIndex, details);
        }
Example #7
0
        private void MBtnRestore_Click(object sender, EventArgs e)
        {
            if (!rqRestoreData.IsValid)
            {
                rqRestoreData.ControlToValidate.Focus();

                return;
            }

            try
            {
                Path = mTxtRestorePath.Text;
                RestoreData?.Invoke(this, null);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Có lỗi khi phục hồi dữ liệu: " + ex.Message);
            }
        }
        /// <summary>
        /// Add Heights To A Terrain
        /// </summary>
        /// <param name="terrain">Specific Terrain</param>
        /// <param name="heights">The heights of the terrain</param>
        static void AddModificationData(Terrain terrain, float[,] heights, float[,,] maps)
        {
            RestoreData currentData;

            if (!restoreData.ContainsKey(terrain))
            {
                currentData = new RestoreData();
                restoreData.Add(terrain, currentData);
            }

            currentData = restoreData[terrain];

            if (currentData.hasHeights)
            {
                return;
            }

            currentData.heights = heights;
            currentData.maps    = maps;
        }
        public ActionResult RestoreConfirming(string jwt)
        {
            ar = IsJwtValid(jwt);

            if (ar != null)
            {
                return(ar);
            }

            RestoreData rd = jwtService.GetDataFromJwt(ApiConfig.Options.Restore, jwt) as RestoreData;

            UserAccount userAccount = dbUnit.UserAccountRepository.FindByEmail(rd.Email);

            userAccount.Password = rd.NewPassword;

            dbUnit.UserAccountRepository.Update(userAccount);
            dbUnit.Complete();

            emailService.SendMessage(ApiConfig.Options.RestoreSuccess, userAccount.Email);

            return(Ok(HttpResponseMessages.RestoredSuccess));
        }
Example #10
0
        void RemoveObjects()
        {
            var        elementNetType = list.GetType().GetGenericArguments()[0];
            MethodInfo methodRemoveAt = list.GetType().GetMethod("RemoveAt");
            var        propertyItem   = list.GetType().GetProperty("Item");

            var reversed = new List <int>(ObjectIndexes);

            reversed.Reverse();

            foreach (var index in reversed)
            {
                //save data to restore
                var data = new RestoreData();
                data.objectToRestore = propertyItem.GetValue(list, new object[] { index });
                dataToRestore[index] = data;

                //remove from the list
                methodRemoveAt.Invoke(list, new object[] { index });
                //ContentBrowserItem_NoSpecialization.AllObjects_PerformChildrenChanged( list );
            }
            //ContentBrowserItem_NoSpecialization.AllObjects_PerformChildrenChanged( list );
        }
    //-------------------------------------------------------------------------
    protected void AddChildColliderDataRecursively(Transform node, string nodePath, ref List <AlphaMeshCollider> collidersList, ref List <RestoreData> dataList, ref List <string> pathsList, ref List <bool> isScaleAnimNodeList)
    {
        foreach (Transform child in node)
        {
            string childNodePath = (nodePath.Length == 0) ? child.name : nodePath + "/" + child.name;

            AlphaMeshCollider alphaMeshColliderComponent = child.GetComponent <AlphaMeshCollider>();
            if (alphaMeshColliderComponent != null)
            {
                MeshCollider meshCollider = alphaMeshColliderComponent.TargetNodeToAttachMeshCollider.gameObject.GetComponent <MeshCollider>();
                if (meshCollider != null)
                {
                    string meshNodePath    = childNodePath;
                    bool   isScaleAnimNode = alphaMeshColliderComponent.ApplySmoothMovesScaleAnim;
                    if (isScaleAnimNode)
                    {
                        meshNodePath += "/" + alphaMeshColliderComponent.TargetNodeNameToAttachMeshCollider;
                    }

                    collidersList.Add(alphaMeshColliderComponent);
                    RestoreData data = new RestoreData();

                    data.mColliderMesh           = meshCollider.sharedMesh;
                    data.mIsTrigger              = meshCollider.isTrigger;
                    data.mConvex                 = meshCollider.convex;
                    data.mSharedMaterial         = meshCollider.sharedMaterial;
                    data.mSmoothSphereCollisions = meshCollider.smoothSphereCollisions;

                    dataList.Add(data);
                    pathsList.Add(meshNodePath);
                    isScaleAnimNodeList.Add(isScaleAnimNode);
                }
            }

            AddChildColliderDataRecursively(child, childNodePath, ref collidersList, ref dataList, ref pathsList, ref isScaleAnimNodeList);
        }
    }
    //-------------------------------------------------------------------------
    protected void AddChildColliderDataRecursively(Transform node, string nodePath, ref List<AlphaMeshCollider> collidersList, ref List<RestoreData> dataList, ref List<string> pathsList, ref List<bool> isScaleAnimNodeList)
    {
        foreach (Transform child in node) {
            string childNodePath = (nodePath.Length == 0) ? child.name : nodePath + "/" + child.name;

            AlphaMeshCollider alphaMeshColliderComponent = child.GetComponent<AlphaMeshCollider>();
            if (alphaMeshColliderComponent != null) {

                MeshCollider meshCollider = alphaMeshColliderComponent.TargetNodeToAttachMeshCollider.gameObject.GetComponent<MeshCollider>();
                if (meshCollider != null) {

                    string meshNodePath = childNodePath;
                    bool isScaleAnimNode = alphaMeshColliderComponent.ApplySmoothMovesScaleAnim;
                    if (isScaleAnimNode) {
                        meshNodePath += "/" + alphaMeshColliderComponent.TargetNodeNameToAttachMeshCollider;
                    }

                    collidersList.Add(alphaMeshColliderComponent);
                    RestoreData data = new RestoreData();

                    data.mColliderMesh = meshCollider.sharedMesh;
                    data.mIsTrigger = meshCollider.isTrigger;
                    data.mConvex = meshCollider.convex;
                    data.mSharedMaterial = meshCollider.sharedMaterial;
                    data.mSmoothSphereCollisions = meshCollider.smoothSphereCollisions;

                    dataList.Add(data);
                    pathsList.Add(meshNodePath);
                    isScaleAnimNodeList.Add(isScaleAnimNode);
                }
            }

            AddChildColliderDataRecursively(child, childNodePath, ref collidersList, ref dataList, ref pathsList, ref isScaleAnimNodeList);
        }
    }
    //-------------------------------------------------------------------------
	protected void AddChildColliderDataRecursively(Transform node, string nodePath, ref List<AlphaMeshCollider> collidersList, ref List<RestoreData> dataList, ref List<string> pathsList, ref List<bool> isScaleAnimNodeList) {
		
		foreach (Transform child in node) {
			string childNodePath = (nodePath.Length == 0) ? child.name : nodePath + "/" + child.name;
			
			AlphaMeshCollider alphaMeshColliderComponent = child.GetComponent<AlphaMeshCollider>();
			if (alphaMeshColliderComponent != null) {

				string colliderNodePath = childNodePath;
				bool isScaleAnimNode = alphaMeshColliderComponent.ApplySmoothMovesScaleAnim;
				if (isScaleAnimNode) {
					colliderNodePath += "/" + alphaMeshColliderComponent.TargetNodeNameToAttachMeshCollider;
				}
				
				MeshCollider meshCollider = alphaMeshColliderComponent.TargetNodeToAttachMeshCollider.gameObject.GetComponent<MeshCollider>();
				if (meshCollider != null) {
				
					collidersList.Add(alphaMeshColliderComponent);
					RestoreData data = new RestoreData();
					
					data.mColliderMesh = meshCollider.sharedMesh;
					data.mIsTrigger = meshCollider.isTrigger;
					data.mConvex = meshCollider.convex;
					data.mSharedMaterial = meshCollider.sharedMaterial;
#if !UNITY_5_AND_LATER
					data.mSmoothSphereCollisions = meshCollider.smoothSphereCollisions;
#endif
					
					dataList.Add(data);
					pathsList.Add(colliderNodePath);
					isScaleAnimNodeList.Add(isScaleAnimNode);
				}
#if UNITY_4_3_AND_LATER
				PolygonCollider2D polygonCollider = alphaMeshColliderComponent.TargetNodeToAttachMeshCollider.gameObject.GetComponent<PolygonCollider2D>();
				if (polygonCollider != null) {

					collidersList.Add(alphaMeshColliderComponent);
					RestoreData data = new RestoreData();

					//int numPaths = polygonCollider.pathCount;
					//data.mPolygonColliderPaths = new List<Vector2[]>(numPaths);
					//for (int pathIndex = 0; pathIndex < numPaths; ++pathIndex) {
					//	data.mPolygonColliderPaths[pathIndex] = polygonCollider.GetPath(pathIndex);
					//}
					data.mPolygonColliderPathCount = polygonCollider.pathCount;
					data.mPolygonColliderPoints = polygonCollider.points;

					data.mIsTrigger = polygonCollider.isTrigger;
					// data.mConvex = meshCollider.convex; // Note: polygon colliders have no convex flag.
					data.mSharedMaterial2D = polygonCollider.sharedMaterial;
					//data.mSmoothSphereCollisions = meshCollider.smoothSphereCollisions; // Note: polygon colliders have no smoothSphereCollisions flag.
					
					dataList.Add(data);
					pathsList.Add(colliderNodePath);
					isScaleAnimNodeList.Add(isScaleAnimNode);
				}
#endif
			}
			
			AddChildColliderDataRecursively(child, childNodePath, ref collidersList, ref dataList, ref pathsList, ref isScaleAnimNodeList);
		}
	}
Example #14
0
 internal void AddRestoreData(GeometryObject msaglObject, RestoreData restoreData)
 {
     lock (restoreData)
         restoreDataDictionary[msaglObject] = restoreData;
 }
Example #15
0
    public Player(Dictionary <string, object> json, int index)
    {
        Name   = json.String("name");
        Avatar = json.String("avatar");
        Uid    = json.String("uid");

        // 用户记分牌
        Bankroll.Value = json.Int("bankroll");

        // 用户该轮上的筹码
        PrChips.Value = json.Int("pr_chips");

        // 用户该手上的总筹码
        Chips = json.Int("chips");

        Index           = index;
        InGame          = json.Bool("is_ingame");
        AuditCD         = json.Int("unaudit_countdown");
        Coins           = json.Int("coins");
        Rank.Value      = GameData.Shared.Type.Value == GameType.MTT ? json.Int("rank") : json.Int("match_rank");
        readyState      = json.Int("is_ready");
        HeadValue.Value = json.Int("head_value");

        if (json.Bool("is_allin"))
        {
            ActState.OnNext(ActionState.Allin);
        }
        else if (json.Int("tonic_blind") == 1)
        {
            ActState.OnNext(ActionState.TonicBlind);
        }
        else if (json.Int("straddle") == 1)
        {
            ActState.OnNext(ActionState.Straddle);
        }
        else
        {
            ActState.OnNext(json.String("last_act").ToActionEnum());
        }


        if (GameData.Shared.IsMatch())
        {
            AddonCount = json.Int("add_on");
            RebuyCount = json.Int("rebuy_count");
        }

        if (json.ContainsKey("win_rate"))
        {
            WinPercent.OnNext(json.Int("win_rate"));
        }

        ShowCard.Value = Convert.ToString(json.Int("showcard"), 2);

        var trust = json.Dict("trust");

        SetTrust(trust);

        var cd = json.Int("turn_countdown");

        if (cd > 0)
        {
            var dt = new RestoreData();
            dt.seconds = cd;
            dt.data    = new Dictionary <string, object> {
                { "cmds", json.Dict("cmds") }
            };
            dt.BuyTimeCost = json.Int("show_moretime");

            Countdown.OnNext(dt);
        }

        var cards = json.IL("cards");

        Cards.OnNext(cards);

        var state = json.Int("gamer_state");
        var ucd   = json.Int("unseat_countdown");

        SetState(state, ucd);
    }
Example #16
0
        void DeleteObjects()
        {
            ContentBrowserUtility.AllContentBrowsers_SuspendChildrenChangedEvent();
            ESet <ComponentHierarchyController> controllersToProcessDelayedOperations = new ESet <ComponentHierarchyController>();

            List <Component> deleted = new List <Component>();

            try
            {
                foreach (var obj in Objects)
                {
                    var parent = obj.Parent;
                    if (parent != null)
                    {
                        RestoreData data = new RestoreData();
                        data.parent      = parent;
                        data.insertIndex = parent.Components.IndexOf(obj);

                        dataToRestore[obj] = data;

                        obj.RemoveFromParent(true);

                        deleted.Add(obj);

                        if (obj.ParentRoot?.HierarchyController != null)
                        {
                            controllersToProcessDelayedOperations.AddWithCheckAlreadyContained(obj.ParentRoot?.HierarchyController);
                        }
                    }
                }
            }
            finally
            {
                foreach (var c in controllersToProcessDelayedOperations)
                {
                    c.ProcessDelayedOperations();
                }
                ContentBrowserUtility.AllContentBrowsers_ResumeChildrenChangedEvent();
            }

            //update selected objects for document windows
            if (document != null)
            {
                foreach (var window in EditorAPI.GetAllDocumentWindowsOfDocument(document))
                {
                    var  selectedObjects = new ESet <object>(window.SelectedObjectsSet);
                    bool updated         = false;

                    foreach (var obj in deleted)
                    {
                        if (selectedObjects.Remove(obj))
                        {
                            updated = true;
                        }
                    }

                    if (updated)
                    {
                        window.SelectObjects(selectedObjects);
                    }
                }
            }
            //!!!!так?
            //!!!!!!как-то слишком низкоуровнего из-за documentWindow?
            //if( SettingsWindow.Instance != null )
            //{
            //	SettingsWindow.PanelData panel = SettingsWindow.Instance.SelectedPanel;
            //	if( panel != null )
            //	{
            //		var selectedObjects = new ESet<object>( SettingsWindow.Instance.SelectedObjectsSet );

            //		foreach( var obj in deleted )
            //			selectedObjects.Remove( obj );

            //		if( !ESet<object>.IsEqual( selectedObjects, SettingsWindow.Instance.SelectedObjectsSet ) )
            //			SettingsWindow.Instance.SelectObjects( panel.documentWindow, selectedObjects );
            //	}
            //}
        }
        private static bool AreOutputsUpToDate(string assetsFilePath, string cacheFilePath, string targetsFilePath, string propsFilePath, string lockFilePath, string globalPackagesFolderPath, RestoreData outputWriteTime)
        {
            DateTime currentAssetsFileWriteTime       = GetLastWriteTime(assetsFilePath);
            DateTime currentCacheFilePath             = GetLastWriteTime(cacheFilePath);
            DateTime currentTargetsFilePath           = GetLastWriteTime(targetsFilePath);
            DateTime currentPropsFilePath             = GetLastWriteTime(propsFilePath);
            DateTime currentLockFilePath              = GetLastWriteTime(lockFilePath);
            DateTime globalPackagesFolderCreationTime = GetCreationTime(globalPackagesFolderPath);

            return(outputWriteTime._lastAssetsFileWriteTime.Equals(currentAssetsFileWriteTime) &&
                   outputWriteTime._lastCacheFileWriteTime.Equals(currentCacheFilePath) &&
                   outputWriteTime._lastTargetsFileWriteTime.Equals(currentTargetsFilePath) &&
                   outputWriteTime._lastPropsFileWriteTime.Equals(currentPropsFilePath) &&
                   outputWriteTime._lastLockFileWriteTime.Equals(currentLockFilePath) &&
                   outputWriteTime._globalPackagesFolderCreationTime.Equals(globalPackagesFolderCreationTime));
        }
Example #18
0
    //-------------------------------------------------------------------------
    protected void AddChildColliderDataRecursively(Transform node, string nodePath, ref List <AlphaMeshCollider> collidersList, ref List <RestoreData> dataList, ref List <string> pathsList, ref List <bool> isScaleAnimNodeList)
    {
        foreach (Transform child in node)
        {
            string childNodePath = (nodePath.Length == 0) ? child.name : nodePath + "/" + child.name;

            AlphaMeshCollider alphaMeshColliderComponent = child.GetComponent <AlphaMeshCollider>();
            if (alphaMeshColliderComponent != null)
            {
                string colliderNodePath = childNodePath;
                bool   isScaleAnimNode  = alphaMeshColliderComponent.ApplySmoothMovesScaleAnim;
                if (isScaleAnimNode)
                {
                    colliderNodePath += "/" + alphaMeshColliderComponent.TargetNodeNameToAttachMeshCollider;
                }

                MeshCollider meshCollider = alphaMeshColliderComponent.TargetNodeToAttachMeshCollider.gameObject.GetComponent <MeshCollider>();
                if (meshCollider != null)
                {
                    collidersList.Add(alphaMeshColliderComponent);
                    RestoreData data = new RestoreData();

                    data.mColliderMesh           = meshCollider.sharedMesh;
                    data.mIsTrigger              = meshCollider.isTrigger;
                    data.mConvex                 = meshCollider.convex;
                    data.mSharedMaterial         = meshCollider.sharedMaterial;
                    data.mSmoothSphereCollisions = meshCollider.smoothSphereCollisions;

                    dataList.Add(data);
                    pathsList.Add(colliderNodePath);
                    isScaleAnimNodeList.Add(isScaleAnimNode);
                }
#if UNITY_4_3_AND_LATER
                PolygonCollider2D polygonCollider = alphaMeshColliderComponent.TargetNodeToAttachMeshCollider.gameObject.GetComponent <PolygonCollider2D>();
                if (polygonCollider != null)
                {
                    collidersList.Add(alphaMeshColliderComponent);
                    RestoreData data = new RestoreData();

                    //int numPaths = polygonCollider.pathCount;
                    //data.mPolygonColliderPaths = new List<Vector2[]>(numPaths);
                    //for (int pathIndex = 0; pathIndex < numPaths; ++pathIndex) {
                    //	data.mPolygonColliderPaths[pathIndex] = polygonCollider.GetPath(pathIndex);
                    //}
                    data.mPolygonColliderPathCount = polygonCollider.pathCount;
                    data.mPolygonColliderPoints    = polygonCollider.points;

                    data.mIsTrigger = polygonCollider.isTrigger;
                    // data.mConvex = meshCollider.convex; // Note: polygon colliders have no convex flag.
                    data.mSharedMaterial2D = polygonCollider.sharedMaterial;
                    //data.mSmoothSphereCollisions = meshCollider.smoothSphereCollisions; // Note: polygon colliders have no smoothSphereCollisions flag.

                    dataList.Add(data);
                    pathsList.Add(colliderNodePath);
                    isScaleAnimNodeList.Add(isScaleAnimNode);
                }
#endif
            }

            AddChildColliderDataRecursively(child, childNodePath, ref collidersList, ref dataList, ref pathsList, ref isScaleAnimNodeList);
        }
    }
Example #19
0
    //-------------------------------------------------------------------------
    protected void RestoreColliderData()
    {
        for (int index = 0; index < mDataToRestore.Length; ++index)
        {
            Transform restoreNode = this.transform.Find(mNodePaths[index]);

            RestoreData data            = mDataToRestore[index];
            bool        hasMeshCollider = (data.mColliderMesh != null);
            if (hasMeshCollider)
            {
                MeshCollider collider = restoreNode.GetComponent <MeshCollider>();
                if (collider == null)
                {
                    collider = restoreNode.gameObject.AddComponent <MeshCollider>();
                }
                collider.sharedMesh = null;

                collider.sharedMesh             = data.mColliderMesh;
                collider.isTrigger              = data.mIsTrigger;
                collider.convex                 = data.mConvex;
                collider.sharedMaterial         = data.mSharedMaterial;
                collider.smoothSphereCollisions = data.mSmoothSphereCollisions;
            }
#if UNITY_4_3_AND_LATER
            else               // has a polygon collider
            {
                PolygonCollider2D collider = restoreNode.GetComponent <PolygonCollider2D>();
                if (collider == null)
                {
                    collider = restoreNode.gameObject.AddComponent <PolygonCollider2D>();
                }

                collider.pathCount = data.mPolygonColliderPathCount;
                collider.points    = data.mPolygonColliderPoints;
                collider.isTrigger = data.mIsTrigger;
                //collider.convex = data.mConvex; // Note: polygon colliders have no convex flag.
                collider.sharedMaterial = data.mSharedMaterial2D;
                //collider.smoothSphereCollisions = data.mSmoothSphereCollisions; // Note: polygon colliders have no smoothSphereCollisions flag.
            }
#endif

            Transform referenceColliderNode        = restoreNode;
            bool      parentHoldsReferenceCollider = mIsSmoothMovesScaleAnimAppliedAtNode[index];
            if (parentHoldsReferenceCollider)
            {
                referenceColliderNode = restoreNode.transform.parent;
            }

            bool hasSmoothMovesCollider = referenceColliderNode.GetComponent <BoxCollider>();
            if (!hasSmoothMovesCollider)
            {
                hasSmoothMovesCollider = referenceColliderNode.GetComponent <SphereCollider>();
            }

            if (hasSmoothMovesCollider)
            {
                // copy the SmoothMoves collider's enabled state at runtime.
                AlphaMeshColliderCopyColliderEnabled copyStateComponent = restoreNode.GetComponent <AlphaMeshColliderCopyColliderEnabled>();
                if (copyStateComponent == null)
                {
                    copyStateComponent = restoreNode.gameObject.AddComponent <AlphaMeshColliderCopyColliderEnabled>();
                }
            }
        }
    }