예제 #1
0
 public virtual void applyMovement(VGDLGame game, Vector2 action)
 {
     if (!physicstype.CompareAndIgnoreCase("GRID"))
     {
         updatePassive();
     }
     lastMovementType = physics.activeMovement(this, action, speed);
 }
예제 #2
0
    //TODO: THINK ABOUT INPUTS SOME MORE!!!
    //Java version uses KeyMasks to store AvatarActions between updates, and classes like FlakAvatar exploits that.
    //Something about limiting the actions up front, instead of after the fact feels better to me.

    /**
     * This update call is for the game tick() loop.
     * @param game current state of the game.
     */
    public virtual void updateAvatar(VGDLGame game, bool requestInput, List <VGDLAvatarActions> actionMask = null)
    {
        lastMovementType = VGDLMovementTypes.STILL;

        var direction = VGDLUtils.VGDLDirections.NONE.getDirection();

        if (requestInput || actionMask == null)
        {
            //Get the input from the player.
            VGDLAvatarActions action;
            if (player != null && player.isHuman)
            {
                if (inputHandler.ProcessEscapeInput(playerID))
                {
                    game.Abort();
                    action = VGDLAvatarActions.ACTION_ESCAPE;
                }
                //TODO: CHECK IF actions INCLUDE USE KEY!
                else if (inputHandler.ProcessUseInput(playerID))
                {
                    //NOTE: technically we could allow directional input + use
                    action = VGDLAvatarActions.ACTION_USE;
                }
                else
                {
                    //TODO: CHECK IF actions INCLUDE DIRECTIONS!
                    direction = inputHandler.ProcessPlayerMovement(playerID, true);
                    //NOTE: For now we don't handle multiple actions at once, so this is okay.
                    //But if/when that happens, the AvatarActions need to deal with that.
                    action = AvatarAction.fromVector(direction);
                }

                player.logAction(action);
                game.avatarLastAction[playerID] = action;
            }
            else
            {
                if (player == null)
                {
                    Debug.LogError("No player attached to avatar: " + getType());
                    return;
                }

                action    = requestAgentInput(game);
                direction = action.getDirection();
            }
        }
        else
        {
            direction = inputHandler.ProcessPlayerInput(actionMask);
        }

        //Apply the physical movement.
        applyMovement(game, direction);
    }
예제 #3
0
    public VGDLAvatar(VGDLAvatar from) : base(from)
    {
        //Insert fields to be copied by copy constructor.
        actions.AddRange(from.actions);
        actionsNIL.AddRange(from.actionsNIL);

        playerID        = from.playerID;
        winState        = from.winState;
        score           = from.score;
        is_disqualified = from.is_disqualified;

        //Don't know about this one
        //inputHandler = from.inputHandler;
        setKeyHandler(from.getKeyHandler());
        lastMovementType = from.lastMovementType;
    }