// Use this for initialization
 void Start()
 {
     if (Configuration == null)
     {
         Configuration = new Ballistics.ProjectileConfiguration();
     }
 }
예제 #2
0
        private void SetSelection(Ballistics.IProjectileConfiguration config)
        {
            List <CUBSPartDisplayWidget> widgets = new List <CUBSPartDisplayWidget>(GetComponentsInChildren <CUBSPartDisplayWidget>());

            SetHeight(config.Parts.Count);
            bool isWidgetLayoutChanged = false;

            //add any extra widgets we may need
            while (config.Parts.Count > widgets.Count)
            {
                widgets.Add(ObjectPool.Spawn(partDisplayButtonPrefab));
            }
            //set the parts
            for (int idx = 0; idx <= config.Parts.Count; ++idx)
            {
                CUBSPartDisplayWidget nextWidget = widgets[idx];
                nextWidget.Part = config.Parts[idx];
            }
            //clear unused widgets of thier current part
            for (int idx = config.Parts.Count; idx <= widgets.Count; ++idx)
            {
                widgets[idx].Part = null;
            }
            SetHeight(config.Parts.Count);
            if (isWidgetLayoutChanged)
            {
                UpdateLayout(widgets);
            }
        }
        public Projectile GetProjectile(Ballistics.IProjectileConfiguration configuration)
        {
            Projectile projectile = null;

            Debug.Log("Creating a projectile from inventory resources for " + configuration);
            //TRY and get the selected selections from the inventory, and instantiate a projectile
            IProjectileConfiguration selections = this.GetSelections(configuration);

            projectile = new Projectile(selections);
            if (projectile == null || !projectile.CanLaunch())
            {
                Debug.LogWarning("Putting back projectile parts for " + configuration + " due to the projectile not spawning correctly.");
                foreach (PartSelectionBehavior nextSelection in selections.Parts)
                {
                    //place each of the selections back in the inventory, as we cannot use them after all
                    this.Insert(nextSelection);
                }
            }
            else
            {
                //WE SHOULD SETUP THE COLLISION IGNORANCE HERE
                //projectile.ignoreCollisionsWith(this.collider);
            }
            return(projectile);
        }
            private void Launch()
            {
                Ballistics.IProjectileConfiguration selection = this.componentSelector.Configuration;

                Projectile launchable = this.inventory.GetProjectile(selection);

                this.m_launcher.Launch(launchable);
            }
        private IProjectileConfiguration GetSelections(Ballistics.IProjectileConfiguration configuration)
        {
            List <PartSelectionBehavior> lackingComponents = this.GetInsufficientselections(configuration.Parts);

            if (lackingComponents.Count == 0 || infiniteResources)
            {
                //I'm not sure why we ARE making a NEW IProjectileConfiguration here, but it may well be an artifcat of previous design - Ian S.
                IProjectileConfiguration retrievedConfiguration = new ProjectileConfiguration();
                foreach (PartSelectionBehavior nextselectionType in configuration.Parts)
                {
                    retrievedConfiguration.Add(this.Take(nextselectionType));
                }
                return(retrievedConfiguration);
            }
            else
            {
                this.DisplayInsufficientselections(lackingComponents);
                return(null);
            }
        }
예제 #6
0
 public void OnChangeConfiguration(Ballistics.IProjectileConfiguration config)
 {
     Configuration = config;
 }