Exemplo n.º 1
0
 public DefaultActuator(Dictionary<string, Dictionary<string, CharacterActionInterface>> actions, CharacterAbstract character, string initialActionSet)
 {
     if (ActionSetValidator.validate(actions))
     {
         actions_ = actions;
     }
     else
     {
         throw new InvalidActionSetException("This action set is invalid for the DefaultActuator");
     }
     character_ = character;
     currentActionSet_ = initialActionSet;
     currentAction_ = actions_[currentActionSet_]["rest"];
     currentAction_.update();
 }
 public CharacterActionInterface interrupt(CharacterActionInterface newAction)
 {
     if (newAction == this || newAction.getPriority() <= priority_)
     {
         return this;
     }
     newAction.start();
     return newAction;
 }
 public CharacterActionInterface interrupt(CharacterActionInterface newAction)
 {
     if (newAction == this || (newAction.getPriority() <= priority_ && !newAction.isFinished()))
     {
         return this;
     }
     newAction.start();
     return newAction;
 }
Exemplo n.º 4
0
 public void crouch()
 {
     CrouchAction crouch = (CrouchAction)actions_[currentActionSet_]["crouch"];
     currentAction_ = currentAction_.interrupt(crouch);
 }
Exemplo n.º 5
0
 public void cover(CoverObject coverObject)
 {
     CoverActionInterface cover = (CoverActionInterface)actions_[currentActionSet_]["cover"];
     cover.setCover(coverObject);
     currentAction_ = currentAction_.interrupt(cover);
 }
Exemplo n.º 6
0
 public void addAction(CharacterActionInterface action)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 7
0
 public void update()
 {
     Vector2 oldPos = character_.getPosition();
     if (!currentAction_.isFinished())
     {
         currentAction_.update();
     }
     else
     {
         currentAction_ = actions_[currentActionSet_]["rest"];
         currentAction_.update();
     }
     character_.setVelocity(character_.getPosition() - oldPos);
 }
Exemplo n.º 8
0
 public void shoot(RangedWeaponAbstract weapon)
 {
     ShootActionInterface shoot = (ShootActionInterface)actions_[currentActionSet_]["shoot"];
     shoot.shoot(weapon);
     currentAction_ = currentAction_.interrupt(shoot);
 }
Exemplo n.º 9
0
 public void moveTo(Vector2 location)
 {
     MoveToActionInterface moveTo = (MoveToActionInterface)actions_[currentActionSet_]["moveTo"];
     moveTo.moveTo(location);
     /*
     //Or for efficiency's sake
     CharacterActionInterface move = actions_[currentActionSet_]["move"];
     (move as MoveActionInterface).move(direction);
     */
     currentAction_ = currentAction_.interrupt(moveTo);
 }
Exemplo n.º 10
0
 public CharacterActionInterface interrupt(CharacterActionInterface newAction)
 {
     if (newAction == this)
     {
         finished_ = true;
         return this;
     }
     if (newAction.getPriority() <= priority_ && !finished_)
     {
         return this;
     }
     newAction.start();
     return newAction;
 }
Exemplo n.º 11
0
 public CharacterActionInterface interrupt(CharacterActionInterface newAction)
 {
     return newAction;
 }