internal override void HandleEvent(WorldEvent e)
 {
     if (!visible)
     {
         return;
     }
     base.HandleEvent(e);
     if (e.Handled)
     {
         return;
     }
     if (!selected)
     {
         return;
     }
     if (e is KeyDownEvent)
     {
         Keys k = (e as KeyDownEvent).Key;
         if (k == Keys.Back || k == Keys.Delete)
         {
             Input((char)8);
         }
         else if (CommonData.KeyCharMap.Keys.Contains(k))
         {
             Input(CommonData.KeyCharMap[k][InputManager.IsKeyDown(Keys.LeftShift) || InputManager.IsKeyDown(Keys.RightShift) ? 1 : 0]);
         }
     }
 }
Exemple #2
0
 public override void SeparateFrom(Object3D stc)
 {
     if (!Alive)
     {
         return;
     }
     base.SeparateFrom(stc);
     if (stc is IInteractiveObject && InputManager.IsKeyDown(Keys.E))
     {
         ((IInteractiveObject)stc).Interact(this);
     }
     if (stc is IObstacle)
     {
         ((IObstacle)stc).Collide(this);
     }
 }
Exemple #3
0
        public override void Update(GameTime time)
        {
            Vector3 newpos = Position;
            Vector3 newrot = Rotation;

            if (!Attacking && Alive)
            {
                // Vector3 is passed on assignment as a clone not a reference
                if (InputManager.IsKeyDown(Keys.W))
                {
                    if (InputManager.IsKeyDown(Keys.A))
                    {
                        newrot.Y += 0.05f;
                        adjusted  = true;
                    }
                    else if (InputManager.IsKeyDown(Keys.D))
                    {
                        newrot.Y -= 0.05f;
                        adjusted  = true;
                    }
                    else if (!ismoving || !adjusted)
                    {
                        newrot = new Vector3(0, World.GetInstance().ActiveCam.Rotation.Y + (float)Math.PI, 0);
                    }
                    newpos.X += speed * (float)Math.Sin(newrot.Y);
                    newpos.Z += speed * (float)Math.Cos(newrot.Y);
                    ismoving  = true;
                }
                else
                {
                    ismoving = adjusted = false;
                }
                var test = new TimeSpan(0, 0, 1);
                if (ismoving)
                {
                    StarWalking();
                }
                else
                {
                    StandStill();
                }
            }
            int prog = (int)(AnimationProgress * 100);

            if (Alive && ismoving && prog % 50 == 0)
            {
                SoundManager.PlaySound(StepSounds[ran.Next(StepSounds.Length)], SoundCategory.SFX);
            }
            if (Attacking)
            {
                if (prog > 50)
                {
                    OnFinishedPlayingAnimation();
                }
                else if (prog > 20)
                {
                    if (!dgthrown)
                    {
                        ThrowDagger();
                    }
                }
            }
            Position = newpos;
            Rotation = newrot;
            World.GetInstance().ActiveCam.Position = Position + camoffset;
            base.Update(time);
        }