示例#1
0
        /// <summary>
        /// New bullet creation
        /// </summary>
        /// <remarks>Not the bullet spawn, just the container creation, we don't know the bullet name here</remarks>
        /// <returns></returns>
        public BulletMLLib.Bullet CreateBullet(BulletMLLib.Bullet source, bool top)
        {
            // Try to get the parent
            GameObject         gameObject = null;
            BulletSourceScript emitter    = null;

            if (source is TopBullet)
            {
                emitter = ((TopBullet)source).Parent;
                if (emitter != null)
                {
                    gameObject = emitter.gameObject;
                }
            }
            else if (source is BulletObject)
            {
                gameObject = ((BulletObject)source).Parent;
            }

            // Create a top bullet (weird case)
            if (top)
            {
                return(new TopBullet(this, emitter));
            }
            else
            {
                // Create a bullet
                BulletObject bullet = null;
                if (OnBulletCreated != null)
                {
                    bullet = OnBulletCreated(gameObject);
                }
                else
                {
                    bullet = new BulletObject(this, gameObject);
                }
                bullet.OnBulletSpawned += BulletSpawnedHandler;

                return(bullet);
            }
        }
示例#2
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            // Add a button to reload the file
            if (Application.isPlaying)
            {
                if (GUILayout.Button("Reload pattern" + (targets.Length > 1 ? "s" : "")))
                {
                    foreach (var target in targets)
                    {
                        BulletSourceScript pattern = (BulletSourceScript)target;

                        if (pattern.xmlFile != null && Application.isPlaying)
                        {
                            Debug.Log("Reloading pattern " + pattern.xmlFile.name + " for " + pattern.gameObject);
                            pattern.ParsePattern(true);
                            pattern.Initialize();
                        }
                    }
                }
            }
        }
 /// <summary>
 /// New top bullet
 /// </summary>
 /// <param name="bulletManager"></param>
 public TopBullet(BulletMLLib.IBulletManager bulletManager, BulletSourceScript parent)
     : base(bulletManager)
 {
     this.position = Vector2.zero;
     this.Parent   = parent;
 }
示例#4
0
 /// <summary>
 /// New top bullet
 /// </summary>
 /// <param name="bulletManager"></param>
 public TopBullet(BulletMLLib.IBulletManager bulletManager, BulletSourceScript parent)
     : base(bulletManager)
 {
     this.position = Vector2.zero;
       this.Parent = parent;
 }