Ejemplo n.º 1
0
        internal void ChangeStance(PlayerStance newStance, FrameTime frameTime)
        {
            this._currentStance.ExitStance(frameTime);
            this._currentStance = this._stances[(int)newStance];

            if (newStance == PlayerStance.Jumping && this._jumpAudioPlayer.AudioClip != null)
            {
                this._jumpAudioPlayer.Stop();
                this._jumpAudioPlayer.Play();
            }

            this._currentStance.EnterStance(frameTime);
        }
Ejemplo n.º 2
0
        private BaseStance[] GetAllStances()
        {
            var baseStanceType = typeof(BaseStance);
            var types          = Assembly.GetAssembly(baseStanceType).GetTypes().Where(x => x.IsClass && !x.IsAbstract && x.IsSealed && x.IsSubclassOf(baseStanceType));
            var stances        = new BaseStance[Enum.GetNames(typeof(PlayerStance)).Length];

            foreach (var type in types)
            {
                var stance = Activator.CreateInstance(type, this) as BaseStance;
                stances[(int)stance.Stance] = stance;
            }

            return(stances);
        }
Ejemplo n.º 3
0
 public PlayerComponent() : base()
 {
     this._stances       = this.GetAllStances();
     this._currentStance = this._stances[(int)PlayerStance.Walking];
 }