/// <summary>
    /// Checks actor's inventory for projectile, then shoots it from actor's position
    /// </summary>
    /// <param name="actor">Actor</param>
    private void Shoot(Actor actor)
    {
        GameController.Log("Executing ShootCommand on " + actor.name, GameController.LogCommands);

        // Retrieve projectile from actor inventory
        projectile = GetProjectile(actor);

        if (projectile != null)
        {
            // Set bullet on player
            projectile.transform.position = actor.transform.position;

            // Get direction actor is facing (TODO: consider handling this for actors that don't rotate)
            BaseConstants.Direction direction = actor.GetComponent <MoveComponent>().currentDirection;
            GameController.Log("Projectile direction: " + direction.ToString(), GameController.LogCommands);

            // Send projectile in that direction
            Vector2 trajectory = DirectionHelper.DirectionToVector(direction);
            projectile.Shoot(trajectory, actor);
        }
        else
        {
            GameController.LogWarning("Primary Shoot Command: could not find projectile in actor " + actor.name + "'s inventory", GameController.LogCommands);
        }
    }
Пример #2
0
    /// <summary>
    /// Moves player in specified direction.
    /// </summary>
    /// <param name="direction">The direction.</param>
    protected void Move(BaseConstants.Direction direction)
    {
        // Move actor in direction of input
        Vector2 movement = DirectionHelper.DirectionToVector(direction) * moveSpeed;

        rbody.velocity = movement;

        // Save direction to use next frame
        currentDirection = direction;
    }