Inheritance: Component
Ejemplo n.º 1
0
        protected override void Initialize()
        {
            base.Initialize();

            this.playingInstances = new List<Sound3DInstance>();
            this.soundManager = this.EntityManager.Find("soundManager").FindComponent<SoundManager>();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes the fighter controller
        /// </summary>
        protected override void Initialize()
        {
            base.Initialize();

            // Init engine trails
            this.trails = new List<TrailSetting>();

            foreach(var trailEntity in this.Owner.FindChildrenByTag("Trail"))
            {
                Transform3D trailTransform = trailEntity.FindComponent<Transform3D>();
                TrailSetting trail = this.trailManager.GetFreeTrail(trailTransform);

                trail.Thickness = 1;
                trail.ExpirationTime = 1f;
                trail.TimeStep = 0.02;
            }

            // Register fighter in screenplay manager
            var screenplay = this.EntityManager.Find("ScreenplayManager").FindComponent<ScreenplayManager>();
            screenplay.RegisterFighter(new FighterSetting()
                {
                    State = this.State,
                    Transform = transform3D
                });

            this.soundManager = this.EntityManager.Find("SoundManager").FindComponent<SoundManager>();

            // Gets all fighter guns
            this.guns = new List<ProjectileEmitter>();
            var gunEntities = this.Owner.ChildEntities.Where(e => e.Tag == "Gun");
            foreach (var gunEntity in gunEntities)
            {
                var projectileEmitter = gunEntity.FindComponent<ProjectileEmitter>();
                this.guns.Add(projectileEmitter);

                projectileEmitter.OnShoot += projectileEmitter_OnShoot;
            }

            this.laserTrigger.OnActionChange += laserTrigger_OnActionChange;

            // Load sound emitters
            var engineSoundEntity = this.Owner.FindChild("engineSoundEmitter");
            if (engineSoundEntity == null)
            {
                engineSoundEntity = this.Owner;
            }

            this.engineSoundEmitter = engineSoundEntity.FindComponent<SoundEmitter3D>();

            var gunsSoundEntity = this.Owner.FindChild("gunsSoundEmitter");
            if (gunsSoundEntity == null)
            {
                gunsSoundEntity = this.Owner;
            }

            this.gunsSoundEmitter = gunsSoundEntity.FindComponent<SoundEmitter3D>();
        }