コード例 #1
0
ファイル: SoldierController.cs プロジェクト: Trigve/ja2_unity
    //! Convert look direction to move direction.
    static protected ja2.Map.Direction LookDirToMoveDir(ja2.LookDirection Direction)
    {
        ja2.Map.Direction move_dir = ja2.Map.Direction.NONE;
        switch (Direction)
        {
        case ja2.LookDirection.EAST:
            move_dir = ja2.Map.Direction.EAST;
            break;

        case ja2.LookDirection.SOUTHEAST:
            move_dir = ja2.Map.Direction.SOUTH_EAST;
            break;

        case ja2.LookDirection.SOUTH:
            move_dir = ja2.Map.Direction.SOUTH;
            break;

        case ja2.LookDirection.SOUTHWEST:
            move_dir = ja2.Map.Direction.SOUTH_WEST;
            break;

        case ja2.LookDirection.WEST:
            move_dir = ja2.Map.Direction.WEST;
            break;

        case ja2.LookDirection.NORTHWEST:
            move_dir = ja2.Map.Direction.NORTH_WEST;
            break;

        case ja2.LookDirection.NORTH:
            move_dir = ja2.Map.Direction.NORTH;
            break;

        case ja2.LookDirection.NORTHEAST:
            move_dir = ja2.Map.Direction.NORTH_EAST;
            break;
        }

        return(move_dir);
    }
コード例 #2
0
ファイル: SoldierController.cs プロジェクト: Trigve/ja2_unity
    //! Rotate as coroutine
    public IEnumerator Rotate_CoRo(ja2.LookDirection Direction)
    {
        isRotating = true;

        float      time_to_pass   = 0.1f * Mathf.Abs((byte)mercenary.lookDirection - (byte)Direction);
        float      start          = Time.time;
        Quaternion start_rotation = transform.rotation;
        Quaternion end_rotation   = ja2.LookDirectionConverter.DirectionToRotation(Direction);

        while (Time.time - start < time_to_pass)
        {
            // Update rotation of GO
            transform.rotation = Quaternion.Lerp(start_rotation, end_rotation, (Time.time - start) / time_to_pass);
            // Compute actual direction
            mercenary.lookDirection = OrientationFromAngle(transform.rotation);

            yield return(null);
        }
        mercenary.lookDirection = Direction;
        UpdateOrientation();

        isRotating = false;
    }
コード例 #3
0
ファイル: SoldierController.cs プロジェクト: Trigve/ja2_unity
 //! Rotate.
 public void Rotate(ja2.LookDirection Direction)
 {
     StartCoroutine(Rotate_CoRo(Direction));
 }