Ejemplo n.º 1
0
            /// <summary>
            /// remove IGameObject's pair are no longer in collision
            /// </summary>
            public void removeNotCollidableElementsInCurrentFrame(ISceneManager sceneManager)
            {
                if (collisionStateMapByGameObjectPair.Count > 0)
                {

                    for (int i=0; i < collisionStateMapByGameObjectPair.Count; i++ )
                    {
                    //foreach (KeyValuePair<KeyValuePair<IGameObject, IGameObject>, bool> dictionaryElement in collisionRecordDictionary)
                    //{
                        //if (collisionRecordDictionary[dictionaryElement.Key] == false)
                        //{
                        //    collisionRecordDictionary.Remove(dictionaryElement.Key);
                        //    dictionaryElement.Key.Key.onCollisionExitDelegate(dictionaryElement.Key.Value);
                        //    dictionaryElement.Key.Value.onCollisionExitDelegate(dictionaryElement.Key.Key);
                        //}
                        KeyValuePair<IGameObject, IGameObject> gameObjectPair = collisionStateMapByGameObjectPair.ElementAt(i).Key;
                        if (collisionStateMapByGameObjectPair[gameObjectPair] == false)
                        {

                            List<IGameObject> firstGameObjectList = sceneManager.getCollaidableGameObjectList(gameObjectPair.Key.getGameObjectTag());
                            List<IGameObject> secondGameObjectList = sceneManager.getCollaidableGameObjectList(gameObjectPair.Value.getGameObjectTag());

                            if(firstGameObjectList.Contains(gameObjectPair.Key)){
                                gameObjectPair.Key.onCollisionExitDelegate(gameObjectPair.Value);
                            }
                            if (secondGameObjectList.Contains(gameObjectPair.Value))
                            {
                                gameObjectPair.Value.onCollisionExitDelegate(gameObjectPair.Key);
                            }

                            //remove element from dictionary
                            collisionStateMapByGameObjectPair.Remove(gameObjectPair);
                        }

                    }
                }
            }