コード例 #1
0
        public static void RefreshAvailableCollisionObjects(IElement element, CollisionRelationshipViewModel viewModel)
        {
            viewModel.FirstCollisionItemSource.Clear();
            viewModel.SecondCollisionItemSource.Clear();

            var namedObjects = element.AllNamedObjects.ToArray();

            List <string> names = new List <string>();

            // consider:
            // 1. Individual ICollidables
            // 2. Lists of ICollidables
            // 3. TileShapeCollections
            // 4. ShapeCollections

            foreach (var nos in namedObjects)
            {
                bool shouldConsider = GetIfCanBeReferencedByRelationship(nos);

                if (shouldConsider)
                {
                    //names.Add(nos.InstanceName);
                    viewModel.FirstCollisionItemSource.Add(nos.InstanceName);
                    viewModel.SecondCollisionItemSource.Add(nos.InstanceName);
                }
            }
        }
コード例 #2
0
        public static void RefreshSubcollisionObjects(IElement element, CollisionRelationshipViewModel viewModel)
        {
            var firstNos  = element.GetNamedObject(viewModel.FirstCollisionName);
            var secondNos = element.GetNamedObject(viewModel.SecondCollisionName);


            var canFirstHaveSubCollisions  = CanHaveSubCollisions(firstNos);
            var canSecondHaveSubCollisions = CanHaveSubCollisions(secondNos);

            viewModel.FirstSubCollisionEnabled  = canFirstHaveSubCollisions;
            viewModel.SecondSubCollisionEnabled = canSecondHaveSubCollisions;

            if (canFirstHaveSubCollisions)
            {
                var firstEntity = GetEntitySaveReferencedBy(firstNos);

                var list = GetAvailableValues(firstEntity);

                var oldValue = viewModel.FirstSubCollisionSelectedItem;

                viewModel.FirstSubCollisionItemsSource.Clear();
                foreach (var item in list)
                {
                    viewModel.FirstSubCollisionItemsSource.Add(item);
                }

                if (list.Contains(oldValue))
                {
                    viewModel.FirstSubCollisionSelectedItem = oldValue;
                }
            }
            else
            {
                viewModel.FirstSubCollisionSelectedItem = null;
            }

            if (canSecondHaveSubCollisions)
            {
                var secondEntity = GetEntitySaveReferencedBy(secondNos);

                var list = GetAvailableValues(secondEntity);

                var oldValue = viewModel.SecondSubCollisionSelectedItem;

                viewModel.SecondSubCollisionItemsSource.Clear();
                foreach (var item in list)
                {
                    viewModel.SecondSubCollisionItemsSource.Add(item);
                }

                if (list.Contains(oldValue))
                {
                    viewModel.SecondSubCollisionSelectedItem = oldValue;
                }
            }
            else
            {
                viewModel.SecondSubCollisionSelectedItem = null;
            }
        }
コード例 #3
0
        public static CollisionRelationshipViewModel CreateViewModel()
        {
            var viewModel = new CollisionRelationshipViewModel();

            viewModel.PropertyChanged += HandleViewModelPropertyChanged;

            return(viewModel);
        }
コード例 #4
0
        public override void StartUp()
        {
            relationshipViewModel = CollisionRelationshipViewModelController.CreateViewModel();

            collidableViewModel = new CollidableNamedObjectRelationshipViewModel();
            CollidableNamedObjectController.RegisterViewModel(collidableViewModel);

            var collisionCodeGenerator = new CollisionCodeGenerator();

            AvailableAssetTypes.Self.AddAssetType(
                AssetTypeInfoManager.Self.CollisionRelationshipAti);

            RegisterCodeGenerator(collisionCodeGenerator);

            AssignEvents();
        }